NextJS14 w/next-auth on Vercel
Answered
Northeast Congo Lion posted this in #help-forum
Northeast Congo LionOP
Following the tutorial here: (https://nextjs.org/learn/dashboard-app/adding-authentication) and everythign works well deploying to vercel until introduction of next-auth. Locally, setting AUTH_URL and AUTH_SECRET variables in .env works. I created appropriate ENV variables in Vercel (using https://<Deployment_URL/api/auth> to replace http://localhost:3000/api/auth). Error in logs: TypeError: Invalid URL string.
at (node_modules/next-auth/lib/env.js:39:17)
at (node_modules/next-auth/lib/index.js:68:20)
at (node_modules/next-auth/lib/index.js:43:19)
at (node_modules/next/dist/esm/server/web/adapter.js:152:22)
at (node_modules/next/dist/esm/server/async-storage/request-async-storage-wrapper.js:72:23)
at (node_modules/next/dist/esm/server/web/adapter.js:139:52)
Any ideas?
"next": "^14.0.2",
"next-auth": "^5.0.0-beta.4",
at (node_modules/next-auth/lib/env.js:39:17)
at (node_modules/next-auth/lib/index.js:68:20)
at (node_modules/next-auth/lib/index.js:43:19)
at (node_modules/next/dist/esm/server/web/adapter.js:152:22)
at (node_modules/next/dist/esm/server/async-storage/request-async-storage-wrapper.js:72:23)
at (node_modules/next/dist/esm/server/web/adapter.js:139:52)
Any ideas?
"next": "^14.0.2",
"next-auth": "^5.0.0-beta.4",
Answered by Northeast Congo Lion
It looks like the solution was to delete the ENV variable AUTH_URL. Saw this note on next-auth site(https://next-auth.js.org/configuration/options): Using System Environment Variables we automatically detect when you deploy to Vercel so you don't have to define this variable. Make sure Automatically expose System Environment Variables is checked in your Project Settings.
1 Reply
Northeast Congo LionOP
It looks like the solution was to delete the ENV variable AUTH_URL. Saw this note on next-auth site(https://next-auth.js.org/configuration/options): Using System Environment Variables we automatically detect when you deploy to Vercel so you don't have to define this variable. Make sure Automatically expose System Environment Variables is checked in your Project Settings.
Answer