Skip to content

Commit 16d6c00

Browse files
fix: NEXT_PUBLIC_OIDC_SERVER_URL must be set on build to be accessed on client side
1 parent f669e19 commit 16d6c00

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

.github/workflows/cd.yml

+9
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ jobs:
4545
-
4646
name: Generate AUTH_SECRET
4747
run: echo "AUTH_SECRET=$(openssl rand -hex 32)" >> $GITHUB_ENV
48+
# https://nextjs.org/docs/app/building-your-application/configuring/environment-variables#bundling-environment-variables-for-the-browser
49+
-
50+
name: Generate NEXT_PUBLIC_OIDC_SERVER_URL
51+
run: |
52+
if [ "${{ github.event_name }}" == "push" ]; then
53+
echo "NEXT_PUBLIC_OIDC_SERVER_URL=https://demo.api-platform.com/oidc/realms/demo" >> $GITHUB_ENV
54+
else
55+
echo "NEXT_PUBLIC_OIDC_SERVER_URL=https://pr-${{ github.event.pull_request.number }}-demo.api-platform.com/oidc/realms/demo" >> $GITHUB_ENV
56+
fi
4857
-
4958
name: Build Docker images
5059
uses: docker/bake-action@v5

.github/workflows/ci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ jobs:
106106
POSTGRES_PASSWORD: aae5bf316ef5fe87ad806c6a9240fff68bcfdaf7
107107
KEYCLOAK_POSTGRES_PASSWORD: 26d7f630f1524eb210bbf496443f2038a9316e9e
108108
KEYCLOAK_ADMIN_PASSWORD: 2f31e2fad93941b818449fd8d57fd019b6ce7fa5
109+
# https://nextjs.org/docs/app/building-your-application/configuring/environment-variables#bundling-environment-variables-for-the-browser
110+
NEXT_PUBLIC_OIDC_SERVER_URL: https://localhost/oidc/realms/demo
109111
# https://docs.docker.com/compose/environment-variables/envvars/#compose_file
110112
COMPOSE_FILE: compose.yaml:compose.prod.yaml:compose.e2e.yaml
111113
steps:

compose.prod.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ services:
1818
target: prod
1919
args:
2020
AUTH_SECRET: ${AUTH_SECRET}
21+
NEXT_PUBLIC_OIDC_SERVER_URL: ${NEXT_PUBLIC_OIDC_SERVER_URL}
2122
environment:
2223
AUTH_SECRET: ${AUTH_SECRET}
2324

0 commit comments

Comments
 (0)