TIL: API Gateway and CORS preflight request

Every time the browser makes a cross-origin request, it first makes a preflight request to make sure it can actually send the request. Since API Gateway charges per request, you’re billed for both the preflight and the main request.

Even if your API is hosted on a subdomain, e.g. http://api.example.com, the browser still sees it as a cross-origin request from http://example.com. You should move the API to http://example.com/api instead. By hosting under the same domain, you eliminate the need for preflight requests altogether.

I don’t use API Gateway, but this was interesting to know. I use Lambda Function URLs

Source