Safari is where “my CORS setup is fine” goes to die.

I’ve seen teams burn hours staring at Access-Control-Allow-Origin headers while the real problem was Safari’s privacy model, cookie policy, or a cross-site storage assumption that worked everywhere else. If you build anything involving frontend apps, APIs, auth, embedded widgets, or third-party dashboards, you need to treat Safari as a separate threat model and a separate testing target.

CORS is only one layer. Safari’s Intelligent Tracking Prevention (ITP) changes the behavior around cookies, storage, and cross-site identity, which means a request can be perfectly valid from a CORS perspective and still fail in practice.

Here are the mistakes I see most often, and how to fix them.

Mistake 1: Assuming CORS errors are actually CORS errors

Safari loves collapsing different failures into symptoms that look like CORS.

You’ll see frontend code like this:

fetch("https://api.example.com/me", {
  credentials: "include"
})
  .then(r => r.json())
  .then(console.log)
  .catch(console.error);

In Chrome, it works. In Safari, the user appears logged out or the request fails in a way that smells like CORS. So people start changing headers:

Access-Control-Allow-Origin: https://app.example.com
Access-Control-Allow-Credentials: true

Still broken.

That’s because Safari may be blocking the cookie, partitioning storage, or refusing third-party tracking-related behavior before your CORS config even gets a fair shot.

Fix

Debug in layers:

  1. Check whether the request is sent at all.
  2. Check whether cookies are attached.
  3. Check preflight behavior.
  4. Check the actual response headers.
  5. Test whether Safari treats the context as third-party tracking or cross-site embedded content.

When I want to verify headers quickly outside the browser noise, I use HeaderTest. It’s a fast way to confirm whether the server is actually returning the headers you think it is.

Mistake 2: Using wildcard origin with credentials

This is the classic one, and Safari is not forgiving.

If your frontend sends cookies or HTTP auth:

fetch("https://api.example.com/data", {
  credentials: "include"
});

Then this response is invalid for credentialed CORS:

Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true

Browsers reject it. Safari does too.

For comparison, api.github.com legitimately returns:

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 GitHub’s public API use case does not depend on browser credentials in the CORS sense.

Fix

Reflect or explicitly allow the requesting origin when credentials are involved:

const allowedOrigins = new Set([
  "https://app.example.com",
  "https://admin.example.com"
]);

app.use((req, res, next) => {
  const origin = req.headers.origin;
  if (allowedOrigins.has(origin)) {
    res.setHeader("Access-Control-Allow-Origin", origin);
    res.setHeader("Access-Control-Allow-Credentials", "true");
    res.setHeader("Vary", "Origin");
  }
  next();
});

That Vary: Origin matters. Without it, caches can serve the wrong CORS response to the wrong origin.

Mistake 3: Forgetting that Safari blocks third-party cookies aggressively

This is the big ITP trap.

Your app lives on:

  • app.example-app.com

Your API or auth service lives on:

  • auth.example-idp.com

You embed login flows, silent refresh, or session checks in an iframe or cross-site request and expect Safari to send cookies. It often won’t.

This is not “Safari has broken CORS.” This is Safari intentionally reducing cross-site tracking surface.

Fix

Stop relying on third-party cookies for critical auth flows.

Better options:

  • Put app and API on the same site where possible
  • Use top-level navigations for login
  • Use authorization code flow with PKCE for SPAs
  • Move session state to first-party context
  • Design flows that survive blocked third-party cookies

If you control both domains, consolidating under the same registrable domain can help, but don’t oversimplify this. “Same company” is not the same thing as same-site behavior in browsers.

A practical pattern is:

  • frontend: https://app.example.com
  • API: https://api.example.com

Then use secure same-site aware cookies carefully, usually:

Set-Cookie: session=abc123; Path=/; Secure; HttpOnly; SameSite=Lax

Or, if truly required cross-site:

Set-Cookie: session=abc123; Path=/; Secure; HttpOnly; SameSite=None

But SameSite=None is not a magic fix. Safari may still apply ITP restrictions depending on context and tracking classification.

Mistake 4: Breaking preflight with custom headers and then blaming Safari

A lot of Safari “CORS bugs” are just badly handled preflights.

This request triggers preflight:

fetch("https://api.example.com/orders", {
  method: "POST",
  credentials: "include",
  headers: {
    "Content-Type": "application/json",
    "X-CSRF-Token": token
  },
  body: JSON.stringify({ item: 1 })
});

Your server must answer OPTIONS correctly:

Access-Control-Allow-Origin: https://app.example.com
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: POST, OPTIONS
Access-Control-Allow-Headers: Content-Type, X-CSRF-Token
Access-Control-Max-Age: 600
Vary: Origin

Fix

Implement OPTIONS explicitly and test it directly:

app.options("/orders", (req, res) => {
  const origin = req.headers.origin;
  if (origin === "https://app.example.com") {
    res.setHeader("Access-Control-Allow-Origin", origin);
    res.setHeader("Access-Control-Allow-Credentials", "true");
    res.setHeader("Access-Control-Allow-Methods", "POST, OPTIONS");
    res.setHeader("Access-Control-Allow-Headers", "Content-Type, X-CSRF-Token");
    res.setHeader("Access-Control-Max-Age", "600");
    res.setHeader("Vary", "Origin");
  }
  res.sendStatus(204);
});

Also, don’t return a redirect on preflight. Safari tends to be especially annoying around that. Preflight should get a plain success response, not auth middleware, not HTML, not a 301 to another host.

Mistake 5: Exposing too few headers and then wondering why Safari “hides” them

Browsers only expose a limited set of response headers to JavaScript unless you explicitly allow more with Access-Control-Expose-Headers.

If your frontend needs ETag, pagination links, rate limit info, or custom request IDs, you must expose them.

GitHub does this well. Their real response includes:

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

Fix

Expose the headers your app actually reads:

Access-Control-Expose-Headers: ETag, Link, X-Request-Id, X-RateLimit-Remaining

Then in JS:

const res = await fetch("https://api.example.com/items");
console.log(res.headers.get("ETag"));
console.log(res.headers.get("X-RateLimit-Remaining"));

If that returns null, your CORS exposure is incomplete.

Mistake 6: Treating Safari storage access inside iframes like normal app state

If you embed an app or auth flow in an iframe, Safari can block cookie access or local storage assumptions even when your CORS headers are technically correct.

This hits:

  • embedded admin panels
  • white-label widgets
  • SSO session checks
  • payment/account linking flows

Fix

Avoid hidden iframe auth patterns. They’re brittle now.

Prefer:

  • top-level redirect based auth
  • explicit user interaction before storage access
  • server-to-server token exchange where possible

If you’re reaching for weird iframe hacks, stop and redesign the flow. You’re fighting the browser.

Mistake 7: Missing Vary and getting cache-poisoned CORS behavior

This one creates “Safari only” bug reports because browser and CDN caching makes failures inconsistent.

If your server dynamically sets Access-Control-Allow-Origin based on Origin but forgets:

Vary: Origin

A cache may store a response for one origin and serve it to another. Then CORS breaks seemingly at random.

Fix

Any time origin-specific CORS headers are returned, send:

Vary: Origin

And if preflight behavior varies by requested headers or methods, consider:

Vary: Origin, Access-Control-Request-Method, Access-Control-Request-Headers

Mistake 8: Piling on security headers without understanding what they do

I’ve seen teams add random headers hoping one of them fixes Safari. CORS is not fixed by CSP, COOP, or some mystery X- header.

Use the right tool:

  • CORS controls cross-origin read access in browsers
  • Cookie attributes control cookie sending rules
  • ITP affects tracking-related storage/cookie behavior
  • CSP controls what the page can load and execute

If you need to tighten broader header policy, csp-guide.com is a solid reference. Just don’t confuse CSP with CORS. They solve different problems.

A practical Safari-safe checklist

When a cross-origin request fails in Safari, I usually run this checklist:

  1. Is the request same-site or truly cross-site?
  2. Are cookies required?
  3. Are cookies marked Secure and the correct SameSite value?
  4. Is Safari blocking third-party cookie usage because of ITP?
  5. Does the server return a specific Access-Control-Allow-Origin for credentialed requests?
  6. Is Access-Control-Allow-Credentials: true present when needed?
  7. Does preflight return clean 204 or 200 responses with the right allow headers?
  8. Are required response headers listed in Access-Control-Expose-Headers?
  9. Is Vary: Origin present?
  10. Is the auth flow depending on iframes or silent cross-site state access?

That list catches most “Safari CORS” issues because, honestly, many of them aren’t pure CORS issues at all.

Safari forces you to separate cross-origin access control from cross-site identity and storage assumptions. That’s annoying, but it’s also healthy. Once you design with that split in mind, your CORS config gets simpler, your auth flows get more robust, and your bug reports get a lot less mysterious.