CORS Preflight Request Timeout - OPTIONS Request Failing
POST or other non-simple requests fail because the CORS preflight OPTIONS request times out. Browser doesn't even send the actual request.
Requests work in some browsers but not others, or fail intermittently.
Error Messages You Might See
Common Causes
- Server doesn't handle OPTIONS method
- OPTIONS request takes too long to respond
- Firewall blocking OPTIONS method
- CORS headers missing in OPTIONS response
- Preflight cache too short, requesting too frequently
How to Fix It
Ensure server responds to OPTIONS: if(request.method === 'OPTIONS') return new Response(null, { status: 200, headers: corsHeaders })
Response must include CORS headers: 'Access-Control-Allow-Methods', 'Access-Control-Allow-Headers', 'Access-Control-Max-Age'
Set long max-age: 'Access-Control-Max-Age': '86400' (24 hours)
Use middleware to add CORS to all routes
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
What is preflight?
Browser sends OPTIONS request to check if server allows cross-origin request. Server responds with allowed methods/headers
How long should preflight cache?
Access-Control-Max-Age: 86400 (24 hours). Longer is better - fewer OPTIONS requests
Which requests need preflight?
Non-simple: PUT, DELETE, POST with custom headers. Simple: GET, HEAD, POST with form-data