Skip to content

Commit e7b2eb9

Browse files
fix: NEXT_PUBLIC_OIDC_SERVER_URL must be set on build to be accessed on client side (#428)
1 parent f669e19 commit e7b2eb9

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

.github/workflows/cd.yml

Lines changed: 9 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ services:
1818
target: prod
1919
args:
2020
AUTH_SECRET: ${AUTH_SECRET}
21+
# https://nextjs.org/docs/app/building-your-application/configuring/environment-variables#bundling-environment-variables-for-the-browser
22+
NEXT_PUBLIC_OIDC_SERVER_URL: ${NEXT_PUBLIC_OIDC_SERVER_URL}
2123
environment:
2224
AUTH_SECRET: ${AUTH_SECRET}
2325

pwa/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ RUN pnpm fetch --prod
4242
COPY --link . .
4343

4444
ARG AUTH_SECRET
45+
# https://nextjs.org/docs/app/building-your-application/configuring/environment-variables#bundling-environment-variables-for-the-browser
46+
ARG NEXT_PUBLIC_OIDC_SERVER_URL
4547

4648
RUN pnpm install --frozen-lockfile --offline --prod && \
4749
pnpm run build

0 commit comments

Comments
 (0)