I have created a Zero Trust application for a specific route on my backend server. I am calling this route from my frontend server. Even when I have no policies attached, the preflight fails with a CORS 500 error. I have tried all 3 combinations of recommendations – passing the OPTIONS call to my server, having Cloudflare return the values, and even setting up a worker. None of them have gotten past the stage of the preflight rejection. I’ve spent many hours with Claude and even with ChatGPT Deep Research, but the same problem remains no matter what combination of things I try to do.
Ok, I had a core misunderstanding with how workers operate and how they have to be set up.
Core concept: Instead of having your frontend call your backend’s api location, you have Cloudflare create an “{frontend}/api” endpoint, which calls your worker, which then does some hostname regexp stuff and calls your backend.
I still don’t have it working, but I’m getting closer after finally understanding that core principle.
I have my worker set up, but it’s still dying with a 500 before it ever leaves Cloudflare, it’s not getting to my server. I deleted and re-created a service token, but that doesn’t seem to matter.