jessebs
jessebs
KKinde
Created by jessebs on 2/21/2024 in #💻┃support
next.config.js Kinde Env Vars
I'm trying to set some of my KINDE environment variables in my next.config.js file in order to support preview deployments. Here's a minimal example:
...
env: {
KINDE_SITE_URL: "http://localhost:3000",
KINDE_POST_LOGOUT_REDIRECT_URL: "http://localhost:3000",
KINDE_POST_LOGIN_REDIRECT_URL: "http://localhost:3000/dashboard"
}
}

module.exports = nextConfig
...
env: {
KINDE_SITE_URL: "http://localhost:3000",
KINDE_POST_LOGOUT_REDIRECT_URL: "http://localhost:3000",
KINDE_POST_LOGIN_REDIRECT_URL: "http://localhost:3000/dashboard"
}
}

module.exports = nextConfig
I do not have any of the 3 env variables set elsewhere When I visit my application, I get the following error:
⨯ TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:405:5)
at new URL (node:internal/url:676:13)
at new t (/Users/me/projects/my-project/node_modules/@kinde-oss/kinde-auth-nextjs/dist/server/cjs/index.js:1:29570)
at /Users/me/projects/my-project/node_modules/@kinde-oss/kinde-auth-nextjs/dist/server/cjs/index.js:1:30927
at f (/Users/me/projects/my-project/node_modules/@kinde-oss/kinde-auth-nextjs/dist/server/cjs/index.js:1:1537)
at Generator.<anonymous> (/Users/me/projects/my-project/node_modules/@kinde-oss/kinde-auth-nextjs/dist/server/cjs/index.js:1:2887)
... {
input: 'undefined/api/auth/login',
code: 'ERR_INVALID_URL',
page: '/api/auth/[...kindeAuth]'
⨯ TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:405:5)
at new URL (node:internal/url:676:13)
at new t (/Users/me/projects/my-project/node_modules/@kinde-oss/kinde-auth-nextjs/dist/server/cjs/index.js:1:29570)
at /Users/me/projects/my-project/node_modules/@kinde-oss/kinde-auth-nextjs/dist/server/cjs/index.js:1:30927
at f (/Users/me/projects/my-project/node_modules/@kinde-oss/kinde-auth-nextjs/dist/server/cjs/index.js:1:1537)
at Generator.<anonymous> (/Users/me/projects/my-project/node_modules/@kinde-oss/kinde-auth-nextjs/dist/server/cjs/index.js:1:2887)
... {
input: 'undefined/api/auth/login',
code: 'ERR_INVALID_URL',
page: '/api/auth/[...kindeAuth]'
This works if I set the variables through a .env file but my understanding from https://kinde.com/docs/developer-tools/nextjs-sdk/#working-with-preview-urls is that it should work without previously having set the values.
14 replies