CORS: Why Is the Browser Blocking Me?
Work through how browsers handle origins, CORS, preflights, credentials, opaque responses, SameSite cookies, CSP, CSRF, and the classic "but it works in Postman" trap.
Questions
- Not answered. Are these two URLs same-origin?
- Not answered. How are
https://app.example.comandhttps://api.example.comrelated? - Not answered. What does CORS control?
- Not answered. A form-style cross-origin POST changes server state, but the response has no CORS headers. What happens?
- Not answered. Which changes would trigger a CORS preflight?
- Not answered. Which cross-origin requests can avoid a CORS preflight?
- Not answered. Which request matches the preflight for a
PATCHwithContent-TypeandX-Trace-Id? - Not answered. Will a CORS preflight include the user's session cookie?
- Not answered. Can
204 No Contentbe a successful preflight response? - Not answered. Your auth middleware returns
401for every unauthenticatedOPTIONSrequest. How should you fix it? - Not answered. A preflight succeeds, then the actual
PATCHreturns500withoutAccess-Control-Allow-Origin. What can browser JavaScript observe? - Not answered. Why might clearing the normal HTTP cache leave a preflight result cached?
- Not answered. Why does
Access-Control-Allow-Origin: *fail forfetch(url, { credentials: "include" })? - Not answered. Which response header pair can share a credentialed response with a page at
https://app.example.com? - Not answered. Will
Access-Control-Allow-Credentials: Trueauthorize a credentialed CORS response? - Not answered. Is
Access-Control-Allow-Origin: https://a.example, https://b.examplea valid two-origin allowlist? - Not answered. Which cache header should you send when
Access-Control-Allow-Originchanges with the request'sOrigin? - Not answered. Why is it dangerous to copy any request
OriginintoAccess-Control-Allow-Originwhen credentials are enabled? - Not answered. What is the default
credentialsmode forfetch("https://api.other.example/data")? - Not answered. What does
credentials: "include"guarantee for a cross-site cookie? - Not answered. Can the browser accept
Set-Cookieeven when CORS prevents JavaScript from reading the response? - Not answered. Does
Access-Control-Allow-Headers: *allow anAuthorizationrequest header? - Not answered. The Network panel shows
X-Request-Id: abc, butresponse.headers.get("X-Request-Id")returnsnull. What is missing? - Not answered. Can frontend JavaScript read
Set-Cookieby asking the server to sendAccess-Control-Expose-Headers: Set-Cookie? - Not answered. What numeric
statusdoes JavaScript observe on an opaque response? - Not answered. What can JavaScript read from a successful cross-origin JSON response fetched with
mode: "no-cors"? - Not answered. Can a
no-corsrequest have server-side effects even though JavaScript receives an opaque response? - Not answered. Why can't a rejected
fetch()promise reliably distinguish a CORS failure from a network failure? - Not answered. What does "it works in the Postman desktop app" prove about a browser CORS failure?
- Not answered. Will a
SameSite=Laxsession cookie accompany a cross-sitefetch()POST from another site? - Not answered. When can a
SameSite=Laxcookie be sent from a cross-site context? - Not answered. What happens to
Set-Cookie: session=abc; SameSite=Nonewhen theSecureattribute is absent? - Not answered. A page on
https://app.example.comfetcheshttps://api.example.com. Which statements are true? - Not answered. Can a browser withhold a cross-site cookie even when Fetch, SameSite, Secure, and CORS are configured correctly?
- Not answered. What protection does
HttpOnlyprovide for a session cookie? - Not answered. Why do cookie-authenticated endpoints still need CSRF protection when their CORS policy is strict?
- Not answered. Why does the page's inline script fail under
Content-Security-Policy: script-src 'self'? - Not answered. Which change allows this inline bootstrap script under CSP?
- Not answered. Why should a CSP nonce not be a constant copied into every response?
- Not answered. Why can one extra space break a CSP hash for an inline script?
- Not answered. The API returns correct CORS headers, but the page has
Content-Security-Policy: connect-src 'self'. Why does the fetch still fail? - Not answered. What does
Content-Security-Policy: default-src 'self'imply for a cross-originfetch()when noconnect-srcis present? - Not answered. How can you test a proposed CSP without enforcing it?
- Not answered. Which limits apply when CSP is delivered through a
<meta>element?