I'm using the new API Gateway HTTP to make requests to 3rd party APIs. This works great for GET requests but doesn't work for POST requests due to CORS preflight.
When I try to make a request this is the error I get on the chrome console...
From the docs it says to add Access-Control-Allow-Methods to * and Access-Control-Allow-Origin to * but POST requests triggers a pre flight request and this is failing.
Any help appreciated!
Double-check your Access-Control-Allow-Headers
. If it's missing any headers that are sent on the request it will silently fail.
I had the same issue (works for GET
but not POST
) because I had forgotten to add the content-type
header to the list. This is a common header sent with POST
requests and I can see it is missing in your example.
It may also help to examine the failed network requests in the browser console to see which headers are being sent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With