Skip to content

fix: auto-inject frontend NEXT_PUBLIC_API_URL from backend service#18

Open
Ho1yShif wants to merge 1 commit into
mainfrom
fix/autoinject-frontend-api-url
Open

fix: auto-inject frontend NEXT_PUBLIC_API_URL from backend service#18
Ho1yShif wants to merge 1 commit into
mainfrom
fix/autoinject-frontend-api-url

Conversation

@Ho1yShif

@Ho1yShif Ho1yShif commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

What

Wires the frontend static site's NEXT_PUBLIC_API_URL to the backend's public URL automatically, instead of requiring a manual value set after the first deploy.

- key: NEXT_PUBLIC_API_URL
  fromService:
    name: pydantic-agents-workflows-api
    type: web
    envVarKey: RENDER_EXTERNAL_URL

Why

The public onrender.com URL isn't a first-class fromService property (only host, port, hostport, connectionString are). But fromService also supports envVarKey, which pulls any env var off another service — including Render's auto-injected RENDER_EXTERNAL_URL (https://<slug>-XXXX.onrender.com).

Benefits:

  • No manual post-deploy step — the value is resolved automatically.
  • Handles the unpredictable -XXXX slug suffix — pulls the real assigned value rather than guessing ${slug}.onrender.com.
  • Works at build timefromService resolves before the static site builds, so NEXT_PUBLIC_API_URL is 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 mutual fromService reference that could error on apply.

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant