feat: runtime-configurable API URL via Next.js API route proxy#112
Merged
Trosper3 merged 1 commit intoJun 19, 2026
Merged
Conversation
Replaces the build-time NEXT_PUBLIC_REDUX_BASE_URL with a server-side REDUX_BASE_URL read at request time via a Next.js API route proxy at /api/redux/[...path]. This allows a single Docker image to target any deployment environment by passing -e REDUX_BASE_URL=... at docker run time — no rebuild required. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Trosper3
approved these changes
Jun 19, 2026
Trosper3
left a comment
Contributor
There was a problem hiding this comment.
Surprising to me still that the old environment variable was baked at build time. I think this will help make our Docker images more flexible.
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.
Closes #99
Summary
NEXT_PUBLIC_REDUX_BASE_URL(baked into the JS bundle at build time) with a server-sideREDUX_BASE_URLread at request time by a Next.js API route proxy at/api/redux/[...path]/api/redux/as its base URL; the proxy forwards all requests to the real API, preserving method, headers, query string, and bodyREDUX_BASE_URLnot set → HTTP 500) or upstream failure (unreachable → HTTP 502)docker runtime:Key files
pages/api/redux/[...path].jspages/index.js/api/redux/.env.developmentREDUX_BASE_URL(value unchanged).env.productionREDUX_BASE_URL(no default baked into image)next.config.jsDockerfileNEXT_PUBLIC_REDUX_BASE_URLbuild argTest plan
REDUX_BASE_URLset; hitting/api/redux/*returns{"error":"REDUX_BASE_URL is not configured"}-e REDUX_BASE_URL=http://redux.thought.net:27000/; real API responded correctly through the proxynpm run devstill useslocalhost:27000via.env.developmentNote on rewrites
The issue proposed using
next.config.jsrewrites. Investigation showed that the rewrite destination is resolved atnext buildtime and compiled intoserver.js— runtime env vars have no effect. An API route is the correct approach for true runtime configurability.🤖 Generated with Claude Code