fix(redirects): manage Render routes in code via API (200-cap + wildcard consolidation)#73
Closed
a-thomas-22 wants to merge 1 commit into
Closed
Conversation
…ard consolidation)
Render caps a static site at 200 routes, and its Blueprint MERGES routes and
never deletes them, so the 215-route set could never sync cleanly. Move route
management out of the Blueprint and into code applied via the Render API:
- redirects.config.js stays the single source of truth (202 entries).
- scripts/sync-render-routes.mjs consolidates to 116 routes (11 verified
prefix-swap wildcard collapses + 94 individuals + SPA fallbacks, ordered
redirects-before-rewrites, deduped) and PUTs them to Render (atomic replace,
PUT /v1/services/{id}/routes), which deletes anything not in the list.
- .github/workflows/render-routes.yml validates the set on every PR and applies
it on push to main (needs RENDER_API_KEY + RENDER_SERVICE_ID secrets).
- render.yaml keeps only service config (no routes block).
- Remove the obsolete render.yaml splice script + redirects-in-sync workflow.
Verified end-to-end on a throwaway Render service: the 116-route set PUT
successfully and legacy URLs (including wildcard tails) return 301s.
|
@a-thomas-22 is attempting to deploy a commit to the zero-dev1 Team on Vercel. A member of the Team first needs to authorize it. |
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.
Root cause (finally)
Two hard Render constraints, confirmed empirically + via Render docs:
/resources/infrastructure/apiwas a red herring — it was simply route #201.)render.yaml-defined routes accumulate and drift, and can't be cleanly curated.Together these make the Blueprint a poor place to own a redirect set. So routes move into code, applied via the Render API.
Approach
redirects.config.jsstays the single source of truth (202 entries).scripts/sync-render-routes.mjsconsolidates to 116 routes and applies them viaPUT /v1/services/{id}/routes(atomic replace — deletes anything not in the list, priority = list order):/react/* → /advanced/react-hooks/*,/resources/* → /api-and-toolings/*) replace 97 individual redirects. Each collapse is checked at build time — if any member isn't a clean tail-preserving swap, it's skipped and stays individual..github/workflows/render-routes.ymlvalidates on every PR (no secrets) and applies on push tomain(needsRENDER_API_KEY+RENDER_SERVICE_IDsecrets).render.yamlkeeps only service config (build/domains/env) — noroutesblock, so the Blueprint manages infra and never fights the API-managed routes.render.yamlsplice script andredirects-in-syncworkflow.Behavior note
The 11 collapses are catch-alls (e.g. any
/react/...now redirects to/advanced/react-hooks/...), so unlisted sub-paths redirect too instead of 404ing — generally an improvement. All 201 originally-mapped URLs resolve identically.Verified end-to-end
On a throwaway Render static site, the 116-route set
PUTsucceeded and legacy URLs return correct 301s:Before this works in prod
RENDER_API_KEYandRENDER_SERVICE_ID(srv-cm3hg30cmk4c73cd5nd0).