Speeding up CORS preflight requests with Cloudflare Workers

As a security measure browsers perform CORS preflight requests, but sometimes those preflight requests add significant latency - for example if your CORS-enabled API is hosted in single location and you have users all across the world. Some users located far away from your API server might need to wait extra 200-300ms to just get CORS response. This can be improved by routing all OPTIONS requests to Cloudflare Worker that should respond quickly no matter where your users are.