bug/request: No redirection to the Google authentication service #1204

Closed
opened 2026-03-13 08:28:04 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @Oxygen66 on GitHub (May 14, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  • Create server action:
'use server'
export async function signInWithGoogle() {
  await auth.api.signInSocial({ // backend auth config (below)
    body: {
      provider: "google",
    },
  });
}

Current vs. Expected behavior

Current: No redirection to the Google authentication service
Expected: Redirection to google

What version of Better Auth are you using?

1.2.7

Provide environment information

- OS: Mac OS 15.4.1
- Browser: Chrome 136.0.7103.93

Which area(s) are affected? (Select all that apply)

Backend

Auth config (if applicable)

```ts
import { prisma } from "@/prisma";
// eslint-disable-next-line no-restricted-imports
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { nextCookies } from "better-auth/next-js";

export const auth = betterAuth({
  database: prismaAdapter(prisma, {
    provider: "postgresql",
  }),
  advanced: {
    database: {
      generateId: false,
    },
  },
  socialProviders: {
    google: {
      clientId: process.env.GOOGLE_CLIENT_ID as string,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
      disableImplicitSignUp: true,
    },
  },
  user: {
    modelName: "User",
    additionalFields: {
      role: {
        type: "string",
        // enum: ["admin", "user"],
      },
    },
  },
  account: {
    modelName: "Account",
  },
  session: {
    modelName: "Session",
  },
  verification: {
    modelName: "Verification",
  },
  plugins: [nextCookies()],
});

Additional context

No response

Originally created by @Oxygen66 on GitHub (May 14, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce - Create server action: ```ts 'use server' export async function signInWithGoogle() { await auth.api.signInSocial({ // backend auth config (below) body: { provider: "google", }, }); } ``` ### Current vs. Expected behavior Current: No redirection to the Google authentication service Expected: Redirection to google ### What version of Better Auth are you using? 1.2.7 ### Provide environment information ```bash - OS: Mac OS 15.4.1 - Browser: Chrome 136.0.7103.93 ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript ```ts import { prisma } from "@/prisma"; // eslint-disable-next-line no-restricted-imports import { betterAuth } from "better-auth"; import { prismaAdapter } from "better-auth/adapters/prisma"; import { nextCookies } from "better-auth/next-js"; export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: "postgresql", }), advanced: { database: { generateId: false, }, }, socialProviders: { google: { clientId: process.env.GOOGLE_CLIENT_ID as string, clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, disableImplicitSignUp: true, }, }, user: { modelName: "User", additionalFields: { role: { type: "string", // enum: ["admin", "user"], }, }, }, account: { modelName: "Account", }, session: { modelName: "Session", }, verification: { modelName: "Verification", }, plugins: [nextCookies()], }); ``` ### Additional context _No response_
Author
Owner

@Oxygen66 commented on GitHub (May 15, 2025):

After investigating your source code, I noticed that you didn't do any redirection when calling "signInSocial"...
Could you add a ‘redirect: boolean’ field to the body? Even if it's false by default ...

BTW, I don't see any documentation of what your API returns on the backend: that would have saved me several hours of investigation ^^

@Oxygen66 commented on GitHub (May 15, 2025): After investigating your source code, I noticed that you didn't do any redirection when calling "**signInSocial**"... Could you add a ‘redirect: boolean’ field to the body? Even if it's false by default ... BTW, I don't see any documentation of what your API returns on the backend: that would have saved me several hours of investigation ^^
Author
Owner

@Kinfe123 commented on GitHub (Jun 8, 2025):

You can use the disableRedirect option in the request body to disable automatic redirection to the provider. This is useful if you want to handle the redirection yourself.

@Kinfe123 commented on GitHub (Jun 8, 2025): You can use the disableRedirect option in the request body to disable automatic redirection to the provider. This is useful if you want to handle the redirection yourself.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1204