Google SSO not working
Social auth with google is currently not working for me.
In my production environment and same for demo.better-auth.com/sign-in
14 Replies
It's working on the demo with my email. Can you check what could be the issue locally?
also since the last couple releases, we no longer automatically link accounts if they are registed with another idp
Locally it’s working fine. I already tested it with 2 different google accounts. I’ll check some other devices and browsers.
Sign in with Google is working for you? @bekacru checked it with Safari mobile and Chrome mobile. Sign in with GitHub works
yes it's working for me
what is the error message?
[error] [Better Auth] API Error: FOUND
Session in auth middleware->customRedirect is null
Session in rsc via auth.api.getSession and via authClient is present
Found is just 302 error (redirect)
where does it redirect to?
The redirect specified in the middleware. In demo.better-auth it’s /sign-in. in my application the same
I’ll try to take a look at the catched error in integrations/next-js.ts line 60
Patched a custom console log in the middleware:
[TypeError: fetch failed] {
cause: [Error: C0BC2142EF710000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:ssl/record/ssl3_record.c:354:
] {
library: 'SSL routines',
reason: 'wrong version number',
code: 'ERR_SSL_WRONG_VERSION_NUMBER'
}
}
I have another google account which works by the way.
One Google Workspace account is working, one is not. A normal Google Account is not working. The working one has no profile picture set
Just in case haha
@bekacru Probably unrelated..
The error in demo.better-auth is
account_not_linked
For both of the not working accounts
Yeah this is because of a recent change in account linking. If you've already signed in with a different provider, it won't automatically link anymore unless the provider confirms the email is verified or it's considered a trusted provider.
User & Accounts | Better Auth
user and account management
@bekacru I think the null session issue in the middleware might be related to the request origin. The request URL for the session is currently concatenated with the request origin, but it should use process.env.BETTER_AUTH_URL as the base, if present. Is that correct?
Like
const baseUrl = process.env.BETTER_AUTH_URL || new URL( request.url).origin;
const basePath = options?.basePath || "/api/auth";
const fullURL =
${baseUrl}${basePath}/session;
since it's nextjs we can trust the origin on the request is where the backend is also hosted
Only in case next is the api host
That’s some weird Vercel stuff. On deployments outside of vercel the origin is set to localhost. We can trust our BETTER_AUTH_URL too.
https://community.render.com/t/nextjs-middleware-localhost/10311
https://github.com/vercel/next.js/issues/37536
Render
NextJS Middleware localhost
I deployed a NextJS app on Render. I’m using a middleware to redirect logged out users to my login page (based on Supabase Auth with Next.js | Supabase Docs). However, when I’m deployed on Render, the host URL and port seem incorrect: Mar 17 10:20:23 AM req: { Mar 17 10:20:23 AM cookies: RequestCookies {}, Mar 17 10:20:23 AM geo: {}, M...
GitHub
Hostname of request object in middleware is always 'localhost' · Is...
Verify canary release I verified that the issue exists in Next.js canary release Provide environment information Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 21.5.0: ...
Oh didn't know that. Good catch! Some people have been experiencing issues with the middleware when hosting on a VPS. If you have time, feel free to open a PR, or I'll handle it later.
I’ll open a PR 🙂