Best way to handle HTTP Options calls with fixed responses?


I want to handle all the HTTP Options type calls at the cloudflare level BEFORE it even reaches the origin server to avoid unnecessary load on the server. Current I do not have any load balancer for this service, but rather a dns record which points to the service directly.

What will be the best way to handle such scenario considering cost as well as performance? Is it recommended to create a Load balancer and drop options requests OR handle this via Cloudflare workers? I am new to Cloudflare, so apologies if this is very trivial. Still figuring out stuff :slight_smile:

If you just want to block OPTIONS requests, use a custom WAF rule with the “Request Method” field.

If you want to do something special with them, then use a worker (or maybe a Snippet if you are on a paid plan).

I don’t want to just block. I want to it respond to such requests with 2xx. Like a fixed response. Blocking might end up in failures for the request initiator if am correct.

OK NVM. With Custom WAF rule we also have option to give custom response with options like “custom HTML”, which also allows us to choose which response code we want to send back. So I choose 2xx response code with a fixed response message.

Thank you @sjr for the hint.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.