fix: use server-side KEYCLOAK_URL for Docker JWT verification#554
Open
Rashmil-1999 wants to merge 3 commits intomainfrom
Open
fix: use server-side KEYCLOAK_URL for Docker JWT verification#554Rashmil-1999 wants to merge 3 commits intomainfrom
Rashmil-1999 wants to merge 3 commits intomainfrom
Conversation
…fication In Docker, the frontend container's middleware resolves NEXT_PUBLIC_KEYCLOAK_URL (http://localhost:8080) to itself instead of the keycloak container, causing ECONNREFUSED. Prefer the runtime KEYCLOAK_URL env var (http://keycloak:8080) on the server side for proper Docker DNS resolution.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The internal Docker URL (keycloak:8080) is needed for JWKS key fetching but the issuer claim in JWTs uses Keycloak's public hostname (localhost:8080). Split these concerns so JWKS uses KEYCLOAK_URL and issuer verification uses the public-facing URL matching Keycloak's --hostname setting. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NEXT_PUBLIC_KEYCLOAK_URL(http://localhost:8080) for JWT verification, which resolves to the frontend container itself in Docker — causingECONNREFUSEDgetKeycloakBaseFromHost()now checks the runtimeKEYCLOAK_URLenv var first when running server-side, enabling proper container-to-container communication via Docker DNS (http://keycloak:8080)KEYCLOAK_URL) from JWT issuer verification URL (public-facing, matching Keycloak's--hostnamesetting) to fixjwt issuer invaliderrorsgetKeycloakIssuerBaseUrl()helper and updatedcreateTokenVerifier/verifyTokenAsyncto accept a separate issuer URLNEXT_PUBLIC_KEYCLOAK_URLTest plan
docker compose build frontend)ECONNREFUSEDorjwt issuer invalidin middleware logs)