Merged in feat/env-in-functions (pull request #134)
feat: set NEXTAUTH_URL based on DEPLOY_PRIME_URL on Netlify Approved-by: Simon.Emanuelsson
This commit is contained in:
@@ -12,10 +12,11 @@ CURITY_CLIENT_ID_USER=""
|
|||||||
CURITY_CLIENT_SECRET_USER=""
|
CURITY_CLIENT_SECRET_USER=""
|
||||||
CURITY_ISSUER_USER="https://testlogin.scandichotels.com"
|
CURITY_ISSUER_USER="https://testlogin.scandichotels.com"
|
||||||
CYPRESS_BASE_URL="http://localhost:3000"
|
CYPRESS_BASE_URL="http://localhost:3000"
|
||||||
|
# See next.config.js for info
|
||||||
|
DEPLOY_PRIME_URL="http://localhost:3000"
|
||||||
DESIGN_SYSTEM_ACCESS_TOKEN=""
|
DESIGN_SYSTEM_ACCESS_TOKEN=""
|
||||||
NEXTAUTH_REDIRECT_PROXY_URL="http://localhost:3000/api/web/auth"
|
NEXTAUTH_REDIRECT_PROXY_URL="http://localhost:3000/api/web/auth"
|
||||||
NEXTAUTH_SECRET=""
|
NEXTAUTH_SECRET=""
|
||||||
NEXTAUTH_URL="http://localhost:3000/"
|
|
||||||
REVALIDATE_SECRET=""
|
REVALIDATE_SECRET=""
|
||||||
SEAMLESS_LOGIN_DA="http://www.example.dk/updatelogin"
|
SEAMLESS_LOGIN_DA="http://www.example.dk/updatelogin"
|
||||||
SEAMLESS_LOGIN_DE="http://www.example.de/updatelogin"
|
SEAMLESS_LOGIN_DE="http://www.example.de/updatelogin"
|
||||||
|
|||||||
1
auth.ts
1
auth.ts
@@ -45,7 +45,6 @@ const customProvider = {
|
|||||||
} satisfies OIDCConfig<User>
|
} satisfies OIDCConfig<User>
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
basePath: "/api/web/auth",
|
|
||||||
providers: [customProvider],
|
providers: [customProvider],
|
||||||
redirectProxyUrl: env.NEXTAUTH_REDIRECT_PROXY_URL,
|
redirectProxyUrl: env.NEXTAUTH_REDIRECT_PROXY_URL,
|
||||||
trustHost: true,
|
trustHost: true,
|
||||||
|
|||||||
2
env/server.ts
vendored
2
env/server.ts
vendored
@@ -25,7 +25,6 @@ export const env = createEnv({
|
|||||||
DESIGN_SYSTEM_ACCESS_TOKEN: z.string(),
|
DESIGN_SYSTEM_ACCESS_TOKEN: z.string(),
|
||||||
NEXTAUTH_REDIRECT_PROXY_URL: z.string().optional(),
|
NEXTAUTH_REDIRECT_PROXY_URL: z.string().optional(),
|
||||||
NEXTAUTH_SECRET: z.string(),
|
NEXTAUTH_SECRET: z.string(),
|
||||||
NEXTAUTH_URL: z.string(),
|
|
||||||
NODE_ENV: z.enum(["development", "test", "production"]),
|
NODE_ENV: z.enum(["development", "test", "production"]),
|
||||||
PRINT_QUERY: z.boolean().default(false),
|
PRINT_QUERY: z.boolean().default(false),
|
||||||
REVALIDATE_SECRET: z.string(),
|
REVALIDATE_SECRET: z.string(),
|
||||||
@@ -55,7 +54,6 @@ export const env = createEnv({
|
|||||||
DESIGN_SYSTEM_ACCESS_TOKEN: process.env.DESIGN_SYSTEM_ACCESS_TOKEN,
|
DESIGN_SYSTEM_ACCESS_TOKEN: process.env.DESIGN_SYSTEM_ACCESS_TOKEN,
|
||||||
NEXTAUTH_REDIRECT_PROXY_URL: process.env.NEXTAUTH_REDIRECT_PROXY_URL,
|
NEXTAUTH_REDIRECT_PROXY_URL: process.env.NEXTAUTH_REDIRECT_PROXY_URL,
|
||||||
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
|
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
|
||||||
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
|
|
||||||
NODE_ENV: process.env.NODE_ENV,
|
NODE_ENV: process.env.NODE_ENV,
|
||||||
PRINT_QUERY: process.env.PRINT_QUERY,
|
PRINT_QUERY: process.env.PRINT_QUERY,
|
||||||
REVALIDATE_SECRET: process.env.REVALIDATE_SECRET,
|
REVALIDATE_SECRET: process.env.REVALIDATE_SECRET,
|
||||||
|
|||||||
12
netlify.toml
12
netlify.toml
@@ -2,14 +2,20 @@
|
|||||||
command = "npm run build"
|
command = "npm run build"
|
||||||
publish = ".next"
|
publish = ".next"
|
||||||
|
|
||||||
|
[context.branch-deploy]
|
||||||
|
command = "npm run lint && npm run build"
|
||||||
|
|
||||||
|
[context.deploy-preview]
|
||||||
|
command = "npm run lint && npm run build"
|
||||||
|
|
||||||
[[plugins]]
|
[[plugins]]
|
||||||
package = "netlify-plugin-cypress"
|
package = "netlify-plugin-cypress"
|
||||||
[plugins.inputs]
|
[plugins.inputs]
|
||||||
configFile = "cypress.config.ts"
|
configFile = "cypress.config.ts"
|
||||||
[plugins.inputs.postBuild]
|
[plugins.inputs.postBuild]
|
||||||
enable = true
|
enable = true
|
||||||
start = "npm start"
|
start = "npm start"
|
||||||
wait-on = "http://127.0.0.1:3000/en/test"
|
wait-on = "http://127.0.0.1:3000/en/test"
|
||||||
wait-on-timeout = "30" # seconds
|
wait-on-timeout = "30" # seconds
|
||||||
|
|
||||||
[build.environment]
|
[build.environment]
|
||||||
|
|||||||
@@ -13,8 +13,21 @@ const jiti = createJiti(new URL(import.meta.url).pathname)
|
|||||||
jiti("./env/server")
|
jiti("./env/server")
|
||||||
jiti("./env/client")
|
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} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
|
env: {
|
||||||
|
NEXTAUTH_URL:
|
||||||
|
(process.env.CONTEXT === "production"
|
||||||
|
? process.env.URL
|
||||||
|
: process.env.DEPLOY_PRIME_URL) + "/api/web/auth",
|
||||||
|
},
|
||||||
poweredByHeader: false,
|
poweredByHeader: false,
|
||||||
eslint: { ignoreDuringBuilds: true },
|
eslint: { ignoreDuringBuilds: true },
|
||||||
images: {
|
images: {
|
||||||
|
|||||||
Reference in New Issue
Block a user