Repository navigation
fix(web): answer preflights and encoded paths for moved static assets - #8135
Merged
Merged
Conversation
The moved-asset redirect answered OPTIONS with a 301, which browsers refuse to follow for a preflight, and missed percent-encoded spellings of an old path that servePublicAsset used to decode. Redirect only GET/HEAD so preflights get their 204, and decode the path before the lookup.
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.
Summary
Intent: follow-up to #8134 review. The static.anarlog.so redirect for moved screenshots answered CORS preflights with a 301, which browsers won't follow. It also missed percent-encoded spellings of an old path (e.g.
free%2D11.webp), whichservePublicAssetdecodes. Only GET/HEAD now redirect, so preflights still get a 204, and the path is decoded before the lookup.Demo
N/A: edge cases of the Worker redirect, covered by tests.
Verification
node --test src/cloudflare/static-assets.test.ts(encoded path → 301, OPTIONS → 204)pnpm -F @anlg/web typecheck,pnpm -F @anlg/web test(378 pass)Summary by cubic
Fixes two edge cases in the moved static asset redirect: browsers refuse to follow a 301 on a CORS preflight, and percent-encoded spellings of old paths were previously missed.
servePublicAssetreads paths.Written for commit dd68b1a. Summary will update on new commits.