Preflight requests to static Pages are returning 405
I am trying to use cloudflare pages as static html content fetched by a SPA with a separate FE domain. Since the domains are different, browsers send an OPTIONS pre-flight request for each resource. CF Pages currently returns a 405 status code to any OPTIONS request. Is there a way to handle these pre-flight requests without a worker or CF function since that would get very expensive quickly. I've also tried to bypass these preflight requests to a separate domain with a rewrite rule, but that also gets complicated since it should only happen for OPTIONS methods.
1 Reply
cloudflare pages doesn't natively handle preflight OPTIONS requests, which is why you're getting the 405 status code. without using a worker or function, there’s not a built-in way to manage CORS preflight responses directly.
one workaround is to set up a reverse proxy on a separate server or use a custom domain with proper CORS headers for your static content. you could also explore configuring custom headers through the cloudflare dashboard for your static assets, though that might not fully resolve preflight issues.
if you're avoiding workers for cost reasons, consider limiting preflight requests by optimizing your frontend to reduce CORS requests where possible.