test: add vercel.json config validation tests #439
Merged
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.
Summary
Add tests that validate
app/vercel.jsonis correctly configured for SPA routing.What broke and why
When implementing social preview support (OG tags), I added a root
vercel.jsonto configure API functions. This broke the entire site with 404 errors on all routes because:Root vercel.json overrides app/vercel.json - Vercel uses the config file closest to the project root, so my new root config took precedence over the working
app/vercel.jsonWrong routing config - I tried various approaches (
rewrites,routeswithhandle: filesystem) but none worked correctly because:{ "source": "/(.*)", "destination": "/" }inapp/vercel.jsonSPA routing requires specific config - For React Router to handle client-side routes, all requests must be rewritten to serve
index.html. Without this, direct URL access (e.g., refreshing/uk/research/some-article) returns 404 because Vercel looks for a literal file at that path.Timeline of the incident
vercel.jsonto enable API functionsrouteswith filesystem handlerWhat these tests catch
These tests would have immediately failed when the root
vercel.jsonwas added:And would have caught incorrect rewrite configurations:
Tests added
app/vercel.jsonexistsrewritesarray{ source: "/(.*)", destination: "/" }routesarray (which breaks SPA routing when combined with rewrites)vercel.jsonexists (which caused 404 errors)Test plan
🤖 Generated with Claude Code