I looked at other related questions on SO, but that seems different. In fact, my question is very similar to this , except that I have no problem with 400 status.
Setup:
I used the option "Enable CORS" - I tried to apply this option to both the resource and the POST request (and then deploy the API).
In the GW API, I see the Access-Control-Allow-Origin200 POST response headers listed in the response area of the method.
Result: calling the endpoint from the client code in Chrome, OPTIONS passes, but the POST fails due to the lack of a header Access-Control-Allow-Origin.
In curl: calling OPTIONS
curl -X OPTIONS -H "Access-Control-Request-Method: POST" \
-H "Access-Control-Request-Headers: Content-Type" \
-H "Origin: http://example.com" --verbose <endpoint>
answer:
< HTTP/1.1 200 OK
< Content-Type: application/json
...
< Access-Control-Allow-Headers: Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token
< Access-Control-Allow-Methods: POST,OPTIONS
< Access-Control-Allow-Origin: *
...
but with POST:
curl -X POST -d '{}' -H "Content-Type: application/json" \
-H "Origin: http://example.com" --verbose <endpoint>
it returns:
< HTTP/1.1 200 OK
< Content-Type: application/json
...
and json response body - but no Access-header.
What else can I check?
source
share