fix: auto-inject frontend NEXT_PUBLIC_API_URL from backend service#18
Open
Ho1yShif wants to merge 1 commit into
Open
fix: auto-inject frontend NEXT_PUBLIC_API_URL from backend service#18Ho1yShif wants to merge 1 commit into
Ho1yShif wants to merge 1 commit into
Conversation
Replace the manual `sync: false` on the frontend's NEXT_PUBLIC_API_URL with a `fromService` reference to the backend's Render-injected RENDER_EXTERNAL_URL. This bakes the real public backend URL (including the unpredictable -XXXX slug suffix) into the static build at build time, removing the manual post-deploy step. No cyclic dependency: the backend defaults CORS to "*" and never references the frontend URL, so the dependency is one-directional (frontend -> backend). Co-Authored-By: Claude Opus 4.8 (1M context) <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.
What
Wires the frontend static site's
NEXT_PUBLIC_API_URLto the backend's public URL automatically, instead of requiring a manual value set after the first deploy.Why
The public
onrender.comURL isn't a first-classfromServiceproperty (onlyhost,port,hostport,connectionStringare). ButfromServicealso supportsenvVarKey, which pulls any env var off another service — including Render's auto-injectedRENDER_EXTERNAL_URL(https://<slug>-XXXX.onrender.com).Benefits:
-XXXXslug suffix — pulls the real assigned value rather than guessing${slug}.onrender.com.fromServiceresolves before the static site builds, soNEXT_PUBLIC_API_URLis correctly baked into the bundle.No cyclic dependency
The dependency is one-directional (frontend → backend). The backend defaults CORS to
["*"](backend/config.py) and never references the frontend's URL, so there's no mutualfromServicereference that could error on apply.🤖 Generated with Claude Code