CORS Preflight `OPTIONS` Request Rejected With 401 Unauthorized
Auth middleware required a Bearer token on browser `OPTIONS` preflight (which never sends Authorization).
Runs locally in browser
Free · No login
Independently Verified 2026-11-25
v4.1.0
Identifier: CORS Preflight `OPTIONS` Request Rejected With 401 Unauthorized
Platform: Security
Common Root Causes:
- Auth middleware required a Bearer token on browser `OPTIONS` preflight (which never sends Authorization).
Interactive Diagnostic Checklist
Verified Solutions:
- Allow unauthenticated `OPTIONS` preflight responses returning `204` with CORS allow headers.
Safe Diagnostic Command:
curl -i -X OPTIONS <api-url> -H "Origin: https://app.example.com" -H "Access-Control-Request-Method: POST"
Warning: Verify configuration changes in staging or with dry-run flags (e.g. nginx -t) before reloading production services.
Technical Explanation
Auth middleware required a Bearer token on browser `OPTIONS` preflight (which never sends Authorization). Recommended diagnostic: `curl -i -X OPTIONS <api-url> -H "Origin: https://app.example.com" -H "Access-Control-Request-Method: POST"`. Remediation: Allow unauthenticated `OPTIONS` preflight responses returning `204` with CORS allow headers.
Worked Examples
- Run `curl -i -X OPTIONS <api-url> -H "Origin: https://app.example.com" -H "Access-Control-Request-Method: POST"` to verify root cause before applying the remediation.
Limitations & Assumptions
- Always verify configuration changes in staging or with dry-run flags (e.g. `nginx -t`) before reloading production services.
Source References & Verification
Resource ID: err-cors-preflight-401-unauthorized · Independently verified: 2026-11-25