feat: set NEXTAUTH_URL based on DEPLOY_PRIME_URL on Netlify
This commit is contained in:
@@ -13,8 +13,21 @@ const jiti = createJiti(new URL(import.meta.url).pathname)
|
||||
jiti("./env/server")
|
||||
jiti("./env/client")
|
||||
|
||||
// We set NEXTAUTH_URL here because next.config.js is included in Netlify
|
||||
// functions when bundling. Otherwise we are unable to login on preview
|
||||
// deployments. We use DEPLOY_PRIME_URL from Netlify for all non-production
|
||||
// branches. Locally we set it in .env.local instead of NEXTAUTH_URL.
|
||||
// Netlify`s Next.js Runtime has built-in support for Next-Auth,
|
||||
// but Next-Auth v5 is ESM and therefore not yet handle correctly by Netlify.
|
||||
// This workaround should not be needed once Netlify fixes their code.
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
env: {
|
||||
NEXTAUTH_URL:
|
||||
(process.env.CONTEXT === "production"
|
||||
? process.env.URL
|
||||
: process.env.DEPLOY_PRIME_URL) + "/api/web/auth",
|
||||
},
|
||||
poweredByHeader: false,
|
||||
eslint: { ignoreDuringBuilds: true },
|
||||
images: {
|
||||
|
||||
Reference in New Issue
Block a user