Repository navigation
fix(web): serve markdown before the filesystem check - #7
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
#6 shipped the markdown twins but the negotiation never fired in production:
Accept: text/markdownon/usagestill returned HTML, whileVarywas applied correctly.The cause is Vercel's routing order: redirects, headers, filesystem, then rewrites.
cleanUrlsresolves/usagetousage.htmlat the filesystem stage, and rewrites are only consulted for paths that matched no file, so a rewrite can never take over a URL a static file already answers. Thehascondition was fine; it was simply never reached.Legacy
routesrun before the filesystem check, so that is what this uses. It also fixes the second essential gap for free: onlyroutescan pair adestwith astatus, so an agent that asks for markdown on a dead URL now gets404.mdwith a real 404 status, instead of the HTML page.routescannot be combined withcleanUrls,trailingSlash,headersorrewrites, so those are expressed in the table: asset caching,/x.htmland/x/canonicalisation, the six page URLs,Vary: Accepton every negotiable response, and the 404 fallbacks.Verification
The routing layer only runs on Vercel, so this was checked three ways before pushing:
openapi.vercel.sh/vercel.json).normalizeRoutesfrom@vercel/routing-utils, the check Vercel's own build runs.disttree:Worth confirming against the deployed site once merged, since only the platform proves the last mile.
Summary by cubic
Fixes content negotiation so pages serve Markdown before the filesystem check on Vercel. Previously,
Accept: text/markdownreturned HTML; now the same URL returns its.mdtwin withContent-Type: text/markdown, and dead URLs return404.mdwith a real 404.rewrites/headers/cleanUrls/trailingSlashto legacyroutesso negotiation runs before the filesystem. Adds 308 canonicalization for/x.htmland/x/to/x, and keeps long‑cache for/assets/*.Vary: Accept, Accept-Encodingto negotiated routes and setsContent-Type: text/markdown; charset=utf-8for.md.handle: filesystem: Markdown clients get/404.mdwith 404; others get/404.htmlwith 404.vercel.json(authoritative) andapps/web/vercel.json(mirror). Verify in the deployed environment thatAccept: text/markdownon/,/usage,/playground,/about,/contact,/privacyreturns the.mdbody.Written for commit 228f78a. Summary will update on new commits.