Merged in fix/seamless-login-env-url (pull request #144)

fix(WEB-132): dedidcated URLs for stable environments
This commit is contained in:
Michael Zetterberg
2024-04-26 12:23:26 +00:00
2 changed files with 11 additions and 12 deletions

View File

@@ -17,6 +17,7 @@ DEPLOY_PRIME_URL="http://localhost:3000"
DESIGN_SYSTEM_ACCESS_TOKEN=""
NEXTAUTH_REDIRECT_PROXY_URL="http://localhost:3000/api/web/auth"
NEXTAUTH_SECRET=""
# NEXTAUTH_URL="DO NOT SET THIS HERE, it is managed in next.config.js"
REVALIDATE_SECRET=""
SEAMLESS_LOGIN_DA="http://www.example.dk/updatelogin"
SEAMLESS_LOGIN_DE="http://www.example.de/updatelogin"
@@ -25,4 +26,3 @@ SEAMLESS_LOGIN_FI="http://www.example.fi/updatelogin"
SEAMLESS_LOGIN_NO="http://www.example.no/updatelogin"
SEAMLESS_LOGIN_SV="http://www.example.se/updatelogin"
WEBVIEW_ENCRYPTION_KEY="MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="

View File

@@ -13,24 +13,23 @@ const jiti = createJiti(new URL(import.meta.url).pathname)
jiti("./env/server")
jiti("./env/client")
// We define SCANDIC_ENV_URL for stable environments on Netlify:
// production, stage and test. Avoid using SCANDIC_ENV_URL locally.
// For deployments to those branches we have SCANDIC_ENV_URL defined.
// Otherwise we fallback to DEPLOY_PRIME_URL from Netlify built-in variables.
// Locally we set DEPLOY_PRIME_URL
const ENV_URL = process.env.SCANDIC_ENV_URL || process.env.DEPLOY_PRIME_URL
// 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,
// deployments. 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: {
URL:
process.env.CONTEXT === "production"
? process.env.URL
: process.env.DEPLOY_PRIME_URL,
NEXTAUTH_URL:
(process.env.CONTEXT === "production"
? process.env.URL
: process.env.DEPLOY_PRIME_URL) + "/api/web/auth",
URL: ENV_URL,
NEXTAUTH_URL: `${ENV_URL}/api/web/auth`,
},
poweredByHeader: false,
eslint: { ignoreDuringBuilds: true },