CORS Handbook
The complete guide to understanding and fixing CORS errors.
Built by headertest.com
gRPC-Web looks simple on the surface: your browser app makes RPC calls, your backend answers, everybody wins. Then CORS shows up and turns a clean protocol choice into a deployment problem. I’ve hit this enough times to have a strong opinion: CORS for gRPC-Web is less about “turning on cross-origin access” and more about choosing where protocol translation and policy enforcement should live. That choice affects debugging, security posture, local development, and whether your frontend team hates you by Friday. ...
AWS Lambda Function URLs are one of those features that feel almost suspiciously easy. Click a checkbox, get a public HTTPS endpoint, ship it. Then the browser starts yelling about CORS. I’ve seen this catch people because Function URLs blur two layers together: AWS can add CORS headers for you at the Function URL level. Your Lambda code can also return CORS headers. Mix those carelessly and you get flaky behavior, broken preflights, and confusing browser errors that look unrelated to the actual bug. ...
Cordova apps hit CORS problems in weird ways because they live in an awkward middle ground: web app rules, native wrapper, and sometimes a file:// or custom scheme origin depending on platform and plugin setup. If your API sits behind Apache, you usually fix this in one place: response headers. The hard part is getting the exact combination right for simple requests, preflighted requests, credentials, and legacy Cordova behavior. Here’s the reference I wish more teams had on hand. ...
A lot of CORS bugs are not really CORS bugs. They’re architecture bugs caused by mixing up same-origin and same-site, then trying to patch the fallout with headers until the browser stops complaining. I’ve seen this play out the same way more than once: frontend on app.example.com API on api.example.com session cookie involved somebody says “it’s the same domain, so it should work” someone else adds Access-Control-Allow-Origin: * auth breaks, or worse, security assumptions break Here’s a real-world style case study that shows how teams end up here, what the browser is actually doing, and what the fix looks like. ...
CORS on CloudFront looks simple until caching gets involved. That’s the part that bites people. You add Access-Control-Allow-Origin, test once, it works, then a different origin starts failing or getting the wrong response from cache. If you’ve ever had a “works in curl, fails in browser” day with CloudFront, this is usually why. I’m going to show the setups that actually work in production: static assets behind CloudFront APIs behind CloudFront S3 origins custom origins like ALB, EC2, or API backends dynamic origin allowlists preflight caching without poisoning your edge cache What CloudFront does in a CORS flow CloudFront is a cache and proxy sitting between the browser and your origin. ...
CORS on Google Cloud Load Balancing looks easy right up until the browser starts throwing No 'Access-Control-Allow-Origin' header and your backend logs show perfectly healthy 200 responses. That mismatch is the whole problem: your server can be fine, your load balancer can be fine, and the browser still blocks the response because the headers are wrong, missing, cached badly, or only added on the happy path. I’ve seen the same set of mistakes over and over on Google Cloud external HTTP(S) load balancers. Most of them come down to one thing: treating CORS like an app feature when it’s really a browser contract enforced at the edge. ...
Laravel Sanctum SPA auth looks simple on paper: frontend hits /sanctum/csrf-cookie, then logs in, then sends session cookies with future API requests. The part that trips people up is CORS. Not because CORS is complicated in theory, but because Sanctum relies on cookies + CSRF + stateful requests, and browsers get very picky when credentials are involved. If your React, Vue, or Nuxt frontend lives on http://localhost:5173 and your Laravel API lives on http://localhost:8000, you’re in CORS territory immediately. ...
CORS and rate limiting solve completely different problems, but they collide in production all the time. CORS decides which browser-based origins can read your responses. Rate limiting decides how often a client can hit your API. One is a browser enforcement layer. The other is an abuse-control and fairness layer. They look unrelated until your frontend starts getting mysterious TypeError: Failed to fetch errors right when users hit quota limits. ...
CORS does not magically change because your API moved from HTTP/1.1 or HTTP/2 to HTTP/3. The policy model is the same. The headers are the same. The browser still decides whether frontend JavaScript can read the response. What does change is the transport underneath: QUIC instead of TCP, different connection behavior, different performance characteristics, and a few deployment surprises that show up right next to your CORS config. That distinction matters. I’ve seen teams expect HTTP/3 to “fix” flaky CORS behavior because requests feel different in DevTools. It won’t. If your Access-Control-Allow-Origin policy is wrong, it stays wrong at any HTTP version. ...
CORS gets messy the moment authentication enters the picture. A simple public GET with Access-Control-Allow-Origin: * is easy. GitHub’s API does exactly that for many responses: access-control-allow-origin: * access-control-expose-headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset, Warning That works because a browser can fetch public data without credentials. The moment you send cookies or an Authorization header, the rules change. ...