Repository navigation
fix: frontend configuration externalisation - #2243
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
It changes the wallet frontend’s runtime configuration and deployment contract across Next.js SSR, Docker, Helm, and release publishing, so it needs careful human validation to avoid breaking existing deployments.
Pull request overview
This PR makes the wallet Next.js frontend image environment-agnostic by moving configuration (URLs/theme/feature flags) from build-time NEXT_PUBLIC_* inlining to runtime container environment reads, with Helm values/docs updated accordingly to support “change config + restart pod” deployments.
Changes:
- Introduces a runtime-config mechanism (
runtimeConfig.ts+_document.tsxinjection) and updates frontend pages/utilities to use it instead ofprocess.env.NEXT_PUBLIC_*. - Updates networking/runtime behavior (Socket.IO connection handling, server vs browser backend URL selection) and adds a production
start.jsentrypoint to validate required env vars before serving. - Refactors Dockerfiles, Helm chart values/docs, and the release workflow to remove build-time frontend config.
File summaries
| File | Description |
|---|---|
| packages/wallet/frontend/src/utils/constants.ts | Switch constants to read from injected runtime config (no NEXT_PUBLIC_*). |
| packages/wallet/frontend/src/pages/no-access.tsx | Build auth redirect link from runtime AUTH_HOST. |
| packages/wallet/frontend/src/pages/kyc.tsx | Use runtime BACKEND_URL for browser-facing backend URLs. |
| packages/wallet/frontend/src/pages/grant-interactions/index.tsx | Use runtime AUTH_HOST for interaction redirects. |
| packages/wallet/frontend/src/pages/_document.tsx | Inject runtime config into HTML via inline script; apply runtime theme. |
| packages/wallet/frontend/src/pages/_app.tsx | Use connectToBackend() and force SSR via getInitialProps. |
| packages/wallet/frontend/src/lib/socket.ts | New helper to correctly derive Socket.IO origin/path from BACKEND_URL. |
| packages/wallet/frontend/src/lib/runtimeConfig.ts | New runtime config contract: env read on server + injected window config in browser. |
| packages/wallet/frontend/src/lib/httpClient.ts | Use server-internal backend URL for SSR and injected runtime backend URL in browser. |
| packages/wallet/frontend/scripts/start.js | New production entrypoint to fail fast on missing runtime config. |
| packages/wallet/frontend/next.config.js | Remove build-time env/publicRuntimeConfig usage to avoid freezing config into standalone build. |
| packages/wallet/frontend/Dockerfile.prod | Remove build args/env baking; run start.js before server.js. |
| packages/wallet/frontend/Dockerfile.dev | Remove build-time NEXT_PUBLIC_* args; rely on runtime env. |
| packages/wallet/frontend/.env.local | Update local example to non-NEXT_PUBLIC_* runtime env vars. |
| packages/wallet/frontend/.env.example | Update documentation/comments to reflect runtime-config model and new env var names. |
| helm/testnet-wallet/values.yaml | Add backendInternal and rename frontend ConfigMap keys away from NEXT_PUBLIC_*. |
| helm/testnet-wallet/tests/configMap.frontend_test.yaml | Add Helm unittest coverage for emitted runtime config keys and absence of NEXT_PUBLIC_*. |
| helm/testnet-wallet/README.md | Update chart docs to describe runtime-config keys and behavior. |
| .github/workflows/release.yml | Remove wallet-frontend build-time config inputs; document runtime-config behavior. |
Review details
- Files reviewed: 19/19 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
🎉 This PR is included in version 1.0.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Context
At the moment the way wallet Next.js frontend works is that it bakes every NEXT_PUBLIC_* value into the bundle during build time. The net effect is that if I want to change the URL where the wallet is being served from, then I need to modify the build pipelines and rebuild the whole applications.
This is very limiting and prevents a cluster administrator from making certain changes without involving the development process.
Changes
This pull request refactors how the wallet frontend is configured and deployed, making the image environment-agnostic and simplifying configuration management. All environment variables required by the frontend are now read at runtime from the container environment instead of being baked into the image at build time. This allows a single image to be used across all deployments, with configuration changes requiring only a pod restart rather than a rebuild. The changes also remove the use of
NEXT_PUBLIC_prefixes, update documentation and sample configs, and add tests to ensure the new behavior.