chore(debug): envs in api functions

This commit is contained in:
Michael Zetterberg
2024-05-17 15:16:51 +02:00
parent 53ffe519cd
commit 62a8374144
6 changed files with 66 additions and 38 deletions

View File

@@ -1,40 +1,14 @@
import createJiti from "jiti"
import { login } from "./constants/routes/handleAuth.js"
import {
benefits,
myPages,
overview,
profile,
profileEdit,
stays,
} from "./constants/routes/myPages.js"
import { myPages, overview } from "./constants/routes/myPages.js"
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
console.log({ config_SCANDIC_ENV_URL: process.env.SCANDIC_ENV_URL })
console.log({ config_DEPLOY_PRIME_URL: process.env.DEPLOY_PRIME_URL })
console.log({ ENV_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. 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: ENV_URL,
NEXTAUTH_URL: `${ENV_URL}/api/web/auth`,
},
poweredByHeader: false,
eslint: { ignoreDuringBuilds: true },
images: {