Repository navigation
Restrict the public CORS proxy to allowlisted calling sites - #118
Merged
Merged
Conversation
Add an optional ALLOWED_ORIGINS setting to the proxy core. When set, a request whose Origin is missing, null or unlisted gets the same 404 as a bad token, checked before the edge cache and any upstream fetch; allowed responses echo the caller's origin with Vary: Origin. Targets are never restricted. Refusals are recorded in the stats. The public instance allows savr.link, Netlify preview/branch deploys and localhost. Unset (every self-hosted proxy) behaves as before. Rate limiting is tracked separately in #117. See ADR 0006. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
✅ Deploy Preview for savrlist ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
jonocodes
added a commit
that referenced
this pull request
Oct 16, 2026
The public proxy now refuses unlisted calling sites (#118). The probe must still read as "running" there: an allowed caller gets the CORS 400, a refused one a 404 that still carries CORS headers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Stops other websites from spending the shared proxy's free-tier quota through their visitors' browsers.
ALLOWED_ORIGINSsetting in the proxy core: comma-separated origins,*within a host label (never crosses a.),:*for any port.null/ unlistedOrigin→ the same 404 as a bad token, checked before the edge cache and any upstream fetch. Refusals are recorded in the stats (404/bypass/ no host).Access-Control-Allow-OriginwithVary: Origin.OPTIONSand/healthstay open. Composes withPROXY_TOKENS.[env.public.vars]):https://savr.link,https://*--savrlist.netlify.app,http://localhost:*,http://127.0.0.1:*. Unset (every self-hosted proxy) = unchanged behaviour.Caveats
Origin. Rate limiting is tracked in CORS proxy: consider a Cloudflare rate-limiting rule on the public instance #117.Deploy
Takes effect after
npx wrangler deploy --env publicfrominfra/cors-worker.Test plan
node --test "infra/cors-worker/*.test.mjs" "infra/cors-stats/*.test.mjs"— 61 pass (9 new: allowed origins incl. previews/localhost, refusals incl. dot-crossing and wrong scheme/port, targets unrestricted, cache ordering, token composition, unset = open, stats recording, pattern parsing)curlwithoutOrigingets 404🤖 Generated with Claude Code