Description
When running the Docker image with a custom VITE_POLARIS_API_URL, the app still uses http://polaris:8181 as the OAuth token endpoint unless VITE_OAUTH_TOKEN_URL is also explicitly passed at runtime.
Root cause
The Dockerfile sets ENV VITE_OAUTH_TOKEN_URL=http://polaris:8181/api/catalog/v1/oauth/tokens during the build stage. Vite bakes this into import.meta.env.VITE_OAUTH_TOKEN_URL in the JS bundle.
generate-config.sh writes an empty string for VITE_OAUTH_TOKEN_URL when it is not passed at runtime. The getConfig() function in src/lib/config.ts skips empty strings in window.APP_CONFIG and falls through to import.meta.env — which returns the baked-in polaris:8181 default.
// src/lib/config.ts
function getConfig(key: keyof AppConfig, defaultValue: string = ""): string {
const runtimeValue = window.APP_CONFIG?.[key]
if (runtimeValue !== undefined && runtimeValue !== "") { // empty string is skipped
return runtimeValue
}
const buildTimeValue = import.meta.env[key] // falls through to baked-in default
...
}
Expected behavior
If VITE_OAUTH_TOKEN_URL is not set at runtime, it should be derived from VITE_POLARIS_API_URL at runtime — not from the build-time Dockerfile default.
Steps to reproduce
docker run -p 8080:8080 \
-e VITE_POLARIS_API_URL=http://myhost:8181 \
-e VITE_POLARIS_REALM=myrealm \
-e VITE_POLARIS_PRINCIPAL_SCOPE=PRINCIPAL_ROLE:ALL \
apache/polaris-console:latest
Login fails with ERR_NAME_NOT_RESOLVED for polaris:8181/api/catalog/v1/oauth/tokens despite VITE_POLARIS_API_URL being correctly set.
Workaround
Always pass VITE_OAUTH_TOKEN_URL explicitly:
docker run -p 8080:8080 \
-e VITE_POLARIS_API_URL=http://myhost:8181 \
-e VITE_OAUTH_TOKEN_URL=http://myhost:8181/api/catalog/v1/oauth/tokens \
apache/polaris-console:latest
Suggested fix
In docker/generate-config.sh, derive VITE_OAUTH_TOKEN_URL from VITE_POLARIS_API_URL when not explicitly set:
VITE_OAUTH_TOKEN_URL="${VITE_OAUTH_TOKEN_URL:-${VITE_POLARIS_API_URL}/api/catalog/v1/oauth/tokens}"
This ensures the token URL always follows the API URL unless explicitly overridden.
Description
When running the Docker image with a custom
VITE_POLARIS_API_URL, the app still useshttp://polaris:8181as the OAuth token endpoint unlessVITE_OAUTH_TOKEN_URLis also explicitly passed at runtime.Root cause
The Dockerfile sets
ENV VITE_OAUTH_TOKEN_URL=http://polaris:8181/api/catalog/v1/oauth/tokensduring the build stage. Vite bakes this intoimport.meta.env.VITE_OAUTH_TOKEN_URLin the JS bundle.generate-config.shwrites an empty string forVITE_OAUTH_TOKEN_URLwhen it is not passed at runtime. ThegetConfig()function insrc/lib/config.tsskips empty strings inwindow.APP_CONFIGand falls through toimport.meta.env— which returns the baked-inpolaris:8181default.Expected behavior
If
VITE_OAUTH_TOKEN_URLis not set at runtime, it should be derived fromVITE_POLARIS_API_URLat runtime — not from the build-time Dockerfile default.Steps to reproduce
Login fails with
ERR_NAME_NOT_RESOLVEDforpolaris:8181/api/catalog/v1/oauth/tokensdespiteVITE_POLARIS_API_URLbeing correctly set.Workaround
Always pass
VITE_OAUTH_TOKEN_URLexplicitly:Suggested fix
In
docker/generate-config.sh, deriveVITE_OAUTH_TOKEN_URLfromVITE_POLARIS_API_URLwhen not explicitly set:VITE_OAUTH_TOKEN_URL="${VITE_OAUTH_TOKEN_URL:-${VITE_POLARIS_API_URL}/api/catalog/v1/oauth/tokens}"This ensures the token URL always follows the API URL unless explicitly overridden.