#NextJS14 w/next-auth on Vercel

3 messages · Page 1 of 1 (latest)

sonic rain
#

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",

Add authentication to protect your dashboard routes using NextAuth.js, Server Actions, and Middleware.

undone peakBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

sonic rain
#

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.