fix: Add fallback values for Keycloak environment variables to fix Docker build
CI Pipeline / Backend Build & Test (pull_request) Successful in 52s
CI Pipeline / Frontend Lint, Test & Build (pull_request) Successful in 35s
CI Pipeline / Infrastructure Validation (pull_request) Successful in 3s

The build was failing because KEYCLOAK_ISSUER and KEYCLOAK_CLIENT_ID
were undefined during the static generation phase. Added default values
that match the development configuration.

- Added fallback for KEYCLOAK_ISSUER
- Added fallback for KEYCLOAK_CLIENT_ID
This commit is contained in:
WorkClub Automation
2026-03-20 12:11:22 +01:00
parent 984ab77137
commit 28284d7edc
+2 -2
View File
@@ -24,7 +24,7 @@ declare module "next-auth" {
// In Docker, the Next.js server reaches Keycloak via internal hostname
// (keycloak:8080) but the browser uses localhost:8080. Explicit endpoint
// URLs bypass OIDC discovery, avoiding issuer mismatch validation errors.
const issuerPublic = process.env.KEYCLOAK_ISSUER!
const issuerPublic = process.env.KEYCLOAK_ISSUER || 'http://localhost:8080/realms/workclub'
const issuerInternal = process.env.KEYCLOAK_ISSUER_INTERNAL || issuerPublic
const oidcPublic = `${issuerPublic}/protocol/openid-connect`
const oidcInternal = `${issuerInternal.replace(':8080', ':8081')}/protocol/openid-connect`
@@ -32,7 +32,7 @@ const oidcInternal = `${issuerInternal.replace(':8080', ':8081')}/protocol/openi
export const { handlers, signIn, signOut, auth } = NextAuth({
providers: [
KeycloakProvider({
clientId: process.env.KEYCLOAK_CLIENT_ID!,
clientId: process.env.KEYCLOAK_CLIENT_ID || 'workclub-app',
issuer: issuerPublic,
authorization: {
url: `${oidcPublic}/auth`,