Netlify Preview Deployment NEXTAUTH_URL Support #3176
-
Currently we are deploying our Next.js + NextAuth project on Netlify using its official next.js plugin. Netlify works mostly the same as Vercel where there is is preview deployment for each branch whose URL isn't certain, which causes trouble for the The Vercel preview deployment issue is fixed in next-auth by the I understand that this is a faq of this project (#497, #969, #1156, #2376, etc.) and we have tried various methods & configurations. Yet Netlify doesn't really support context specific runtime environment variable for functions and its official guiding principle on environment variable setup [Support Guide] Using environment variables on Netlify correctly (also see Netlify Functions and Env Variables from netlify.toml) implies that dynamic runtime environment variable should be explicitly exported to somewhere and imported as variable into the function code, which isn't quite compatible with next-auth's guiding principle that https://next-auth.js.org/warnings#nextauth_url NEXTAUTH_URL environment variable not set There should be a sufficient amount of users who are also deploying their next.js + next-auth project on Netlify. Curious how can
Update: Set dynamic |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
there is an ongoing effort to decouple the core of nextauth in a way that would let you create your own wrapper like this file that won't rely on that variable https://github.com/nextauthjs/next-auth/blob/beta/src/next/index.ts See #2294 it's basically done, just not documented yet... Not sure about your side question. haven't tested it, but I would assume it would just work. the next config env variables are inlined build time AFAIK, but nothing else is different. https://nextjs.org/docs/api-reference/next.config.js/environment-variables
|
Beta Was this translation helpful? Give feedback.
there is an ongoing effort to decouple the core of nextauth in a way that would let you create your own wrapper like this file that won't rely on that variable
https://github.com/nextauthjs/next-auth/blob/beta/src/next/index.ts
See #2294
it's basically done, just not documented yet...
Not sure about your side question. haven't tested it, but I would assume it would just work. the next config env variables are inlined build time AFAIK, but nothing else is different.
https://nextjs.org/docs/api-reference/next.config.js/environment-variables