Nitro, Next Auth and Google callback URL

How to setup create-t3-turbo's auth proxy with Google OAuth? I can't get it to work and I think it's because of the callback URLs set in Google Cloud console.
6 Replies
ahkhanjani
ahkhanjani3mo ago
Figured it out. If you're using a subdomain for the auth-proxy project, e.g. auth.yourdomain.com, add this callback URL to Google Cloud dashboard: https://auth.yourdomain.com/callback/google (as you can see there's no /api/auth/). Then since there's a bug (?) in next-auth v5 beta right now (https://github.com/nextauthjs/next-auth/discussions/9748), set basePath: "/" in auth-proxy Auth options so that it won't default to /api/auth/. If the provider in your main project has some options like scope or other things, create a file called packages/auth/src/options.ts and export the options and use it in both projects to get the same behavior everywhere.
GitHub
@auth/core@0.23.0 breaking custom oauth provider · nextauthjs next-...
This issue that was auto closed because I cannot it reproduce the custom OAuth provider part. Can someone help? Provider type Custom provider Environment Deps: next: 14.1.0 react: 18.2.0 next-auth:...
ahkhanjani
ahkhanjani3mo ago
Also with next-auth v5, manually passing provider variables to Discord() or Google() etc. isn't required
julius
julius3mo ago
It isn’t in NextAuth but is in auth/core
ahkhanjani
ahkhanjani3mo ago
Let me figure out why mine is working without them then 🥲 It's totally inferring them. At least I assume so the entire process is working just fine. I couldn't find anything on them being optional or required. The docs are a joke
If the provider in your main project has some options like scope or other things, create a file called packages/auth/src/options.ts and export the options and use it in both projects to get the same behavior everywhere.
I made a PR but left this part out since it's not really relevant to the project itself as it doesn't have any options for discord
Yiannis
Yiannis3mo ago
I think you should include the fact that you need to set up the base path in the proxy server. Had I not come across this thread it would have taken me a while to figure it out. Thanks for finding out about it and thanks to Julius and the community for the whole repo, it's incredible!.
ahkhanjani
ahkhanjani3mo ago
I did not include that because I'm not sure if it should be in the readme since it might be a auth.js bug. But I do think it should be in the code itself for now. I'll leave that to @julius to decide. Here's my PR: https://github.com/t3-oss/create-t3-turbo/pull/914/files#diff-d3db73f679dc5776a7bc9ebd6f10fbb751898e2cab3e33861196b35126476a65