Back

How to implement Google Authentication and deploy web app to Vercel ?

  • 0
  • Auth
  • Web
  • Cloud
richardoey
26 Jun, 2024, 12:23

Hi, I implemented Appwrite Google Authentication in NextJS v14.1.3 and successfully implemented the sign in feature (on SSR) when trying it in localhost, but when deploy to Vercel, I see the console showing this error and not let me sign in, is there any special thing I should do before deploying to Vercel?

I followed SSR tutorial from Appwrite (https://appwrite.io/docs/tutorials/nextjs-ssr-auth/step-7)

Thank you very much for your help !

TL;DR
Developers are having issues implementing Google Authentication on Vercel. They are seeing an "Invalid URL" error in their server log when trying to sign in after deploying to Vercel. They have tried changing the const origin to their Vercel domain but are still facing issues. The error seems to be generated by Vercel. **Solution:** It's suggested to review any logs available on Vercel that might provide more insight on the error. Also, checking if there are any specific configurations needed before deploying to Vercel could help resolve the issue.
Ryan
26 Jun, 2024, 12:28

That looks like an error generated by Vercel, I'm not too familiar with hosting on Vercel, but are there any logs that you're able to access that could show the proper error?

richardoey
26 Jun, 2024, 12:37

Hi Ryan, thank you for replying me!

I just checked again the server log, there is this log

TypeError: Invalid URL at new URL (node:internal/url:797:36) at l.call (/var/task/.next/server/app/signin/page.js:3:105095) at s.createOAuth2Token (/var/task/.next/server/app/signin/page.js:3:125188) at s (/var/task/.next/server/app/signin/page.js:1:13347) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { code: 'ERR_INVALID_URL', input: 'undefined/account/tokens/oauth2/google' }

I wonder, do I need to change the const origin = headers().get("origin"); to be my vercel domain?

Ryan
26 Jun, 2024, 12:40

Changing it to the Vercel domain would definitely work, not sure if this is also worth a look as it lists the headers that are included in deployments https://vercel.com/docs/edge-network/headers#host

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more