Skip to content
AnswerWell geo Documentation

Research · 7 min read · Answerwell

CORS Authorization Cookies, Preflight OPTIONS, and Cross-Origin Troubleshooting

How protected HTTP applications handle cross-origin requests, CF_Authorization cookies, OPTIONS preflight, and common CORS failure modes.

This page summarizes Cloudflare documentation on Cross-Origin Resource Sharing (CORS) for applications fronted by Cloudflare Access. Browsers block many cross-origin reads unless the response includes explicit CORS headers; Access additionally requires a valid authorization cookie on requests that reach the protected origin. The combination produces failures that look like ordinary CORS errors but often involve authentication, OPTIONS preflights, or third-party cookie policies.

Section titled “CF_Authorization cookie: why cross-origin requests need it”

For a CORS request to reach a site protected by Access, the request must include a valid authorization cookie. Cloudflare states:

For a CORS request to reach a site protected by Access, the request must include a valid CF-Authorization cookie.

— Cloudflare, CORS

When you protect a site with Access, Cloudflare checks every HTTP request to ensure it has a valid CF_Authorization cookie; without it, Access blocks the request (Authorization cookie).

Access issues two JWT-bearing cookies by domain:

Cookie role Where it is set Purpose
Global session token Team domain (*.cloudflareaccess.com) SSO across applications
Application token Protected application domain Confirms the user may reach the origin

Both are required cookies for Access functionality and are not used for tracking or analytics, per Access cookies.

Related session cookies include CF_Session and CF_AppSession (CSRF tokens), optional CF_Binding when binding is enabled, and CF_Device on the team domain. Cookie security toggles (SameSite, HttpOnly, binding, path) live under Zero Trust → Access controls → Applications → Configure → Advanced settings → Cookie settings (Cookie settings).

CORS basics: simple requests vs preflighted requests

Section titled “CORS basics: simple requests vs preflighted requests”

CORS uses HTTP response headers so a page on one origin (scheme, host, port) may read responses from another. Access distinguishes:

If you are not logged in, a simple cross-origin request to an Access-protected domain typically surfaces as a browser CORS error. After login, the browser can attach the application CF_Authorization cookie on the actual request (not on OPTIONS—see below).

Browsers also enforce which request headers cross-origin JavaScript may set. The HTML Standard maintains a CORS-approvelisted list (for example content-type); headers such as cookie are non-approvelisted, so scripts cannot arbitrarily attach them— the browser attaches cookies according to cookie rules and your fetch credentials mode.

Preflight OPTIONS and Access: why OPTIONS returns 403

Section titled “Preflight OPTIONS and Access: why OPTIONS returns 403”

Preflighted cross-origin requests fail in a specific way behind Access:

If you make a preflighted cross-origin request to an Access-protected domain, the OPTIONS request will return a 403 error. This error occurs regardless of whether you have logged in to the domain. This is because the browser never includes cookies with OPTIONS requests, by design. Cloudflare will therefore block the preflight request, causing the CORS exchange to fail.

— Cloudflare, Allow preflighted requests

Cloudflare documents three resolutions (Allow preflighted requests):

  1. Bypass OPTIONS requests to origin — send OPTIONS directly to the origin, skipping Access enforcement on that method.
  2. Configure Cloudflare to respond to the OPTIONS request — Access answers preflight without hitting the origin; the follow-up request carries the auth cookie after login.
  3. Cloudflare Worker with authentication token — only when both origins are behind Access.

In Advanced settings → Cross-Origin Resource Sharing (CORS) settings, enable Bypass options requests to origin. Cloudflare notes this removes existing CORS settings for that application and should be used only when the origin already enforces CORS, while you still protect the Access JWT on non-OPTIONS traffic (Bypass OPTIONS requests to origin).

Since 2024-04-28, admins can alternatively defer all CORS enforcement to the origin for specific Access applications (Access changelog).

Match Access CORS settings to headers your origin would return—for example Access-Control-Allow-Origin, Access-Control-Allow-Credentials, Access-Control-Allow-Methods, and Access-Control-Allow-Headers (Configure response to preflight requests). After preflight succeeds, the browser sends the main request, which can include the authentication cookie if the user has logged into the protected domain.

You can sanity-check with:

curl --head --request OPTIONS https://api.mysite.com \
--header 'origin: https://example.com' \
--header 'access-control-request-method: GET'

(Example from Configure response to preflight requests.)

Two Access-protected sites and double login

Section titled “Two Access-protected sites and double login”

If example.com and api.mysite.com are both behind Access, a user logged in only on example.com may lack an application token for api.mysite.com. A Worker can forward authentication credentials so users avoid logging in twice (Send authentication token with Cloudflare Worker).

fetch and AJAX: credentials and missing CORS headers

Section titled “fetch and AJAX: credentials and missing CORS headers”

Access requires explicit credentials when using the Fetch API with cookies:

Cloudflare Access requires that the credentials: same-origin parameter be added to JavaScript when using the Fetch API to include cookies. AJAX requests fail if this parameter is missing, resulting in an error such as No Access-Control-Allow-Origin header is present on the requested resource.

— Cloudflare, Troubleshoot Access

For troubleshooting, Cloudflare also recommends credentials: 'same-origin' on all fetch/XHR calls, and crossorigin="use-credentials" on scripts when using the cross-origin attribute (CORS troubleshooting).

When the console reports CORS “on the same domain,” the request is likely missing CF_Authorization—true same-origin navigation does not run CORS checks (CORS troubleshooting).

Chrome’s broader guidance applies to any credentialed CORS setup: do not use Access-Control-Allow-Origin: * together with Access-Control-Allow-Credentials: true—browsers reject that combination (Web Security — Cross-Origin Resource Sharing).

Third-party cookies, private browsing, and isolated applications

Section titled “Third-party cookies, private browsing, and isolated applications”

Cross-origin fetches often treat the Access authorization cookie like a third-party cookie. Cloudflare warns:

Do not troubleshoot CORS in Incognito mode, as this will cause disruptions with Access due to CF-Authorization being blocked as a third-party cookie on cross origin requests.

— Cloudflare, CORS

Firefox Private Windows may block CF_authorization on XHR; exempt both the application hostname and https://<your-team-name>.cloudflareaccess.com from tracking protection (Troubleshoot Access). Similar steps apply for Chrome, Safari, Firefox, and Brave under Allow third-party cookies in the browser.

Browser Remote Browser Isolation workflows list a prerequisite: the browser must allow third-party cookies on the application domain (Isolate Access applications).

Session errors, Workers on login paths, and binding cookies

Section titled “Session errors, Workers on login paths, and binding cookies”

Invalid session. Please try logging in again means Access could not validate CF_Session—firewalls or split browser contexts between login start and finish are common causes (Troubleshoot Access).

If a Worker route sits on the login path, the Worker may overwrite or strip Set-Cookie for Access cookies; do not modify Access cookie headers in that script (Troubleshoot Access).

Optional binding cookie (CF_Binding) pairs with CF_Authorization so a stolen JWT cannot be reused without the binding cookie; Cloudflare strips CF_Binding at the edge and never forwards it to origin (Binding cookie). Do not enable binding for non-browser tools (SSH/RDP), with incompatible products such as Zaraz (redirect loops), or with Authenticate with Cloudflare One Client enabled.

  • Testing in Incognito or strict third-party cookie modes while debugging Access CORS.
  • Expecting cookies on OPTIONS preflights (browser limitation, not an Access misconfiguration alone).
  • Using fetch without credentials: 'same-origin' (or appropriate credentials mode) when cookies must be sent.
  • Setting Access CORS preflight headers that do not match the origin’s real Access-Control-* policy.
  • Enabling Bypass options requests to origin or origin-deferred CORS without CORS enforcement on the origin.
  • Setting application cookie SameSite to Strict when cross-site or multi-app cookie sharing is required.
  • Caching login HTML at the CDN and stripping Set-Cookie—symptoms overlap with “sessions not persisting” (Dynamic content and login issues); ensure login routes return CF-Cache-Status: DYNAMIC, MISS, or BYPASS and preserve Set-Cookie.

CORS response headers on cached assets may stay stale after origin changes until cache is refreshed or purged (Cross-Origin Resource Sharing (CORS) on cache). That is separate from Access JWT enforcement but produces similar browser errors.

  1. Reproduce in a normal (non-private) browser window with third-party cookies allowed for your application host and https://<your-team-name>.cloudflareaccess.com, as described in Allow third-party cookies in the browser.

  2. Log into the Access-protected API host directly, then repeat the cross-origin call; confirm the main request (not OPTIONS) sends CF_Authorization and your JavaScript uses credentials: 'same-origin' on fetch (Troubleshoot Access).

  3. For preflight failures, send an OPTIONS request with Origin and Access-Control-Request-Method headers and verify whether Access returns 403, your configured CORS headers, or the origin’s headers (Configure response to preflight requests).

  4. Capture a HAR and console log together while reproducing the error (CORS troubleshooting).

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about.