I have:
- Created a static website in AWS S3
- Created an API Gateway resource that calls Lambda
- Enabled CORS on the API Gateway
- Verified the propery CORS response using Postman (returning
Access-Control-Allow-Origin: *
) - Made an AJAX request to the endpoint using
axios.post(...)
Yet, we get the following error:
Failed to load resource: Origin http://mys3site.com is not allowed by Access-Control-Allow-Origin.
This is mind boggling to me because I have clearly enabled a wildcard Access-Control-Allow-Origin
.
Edit
The question was closed because "debugging details are needed". I'm not sure what that means given that this configuration is done through the AWS console rather than through code, but here is my axios post request:
axios.get(ENDPOINT.server) .then((response) => { this.update(response.state); }) .catch((err) => { this.error(err); });
Here are the headers returned by OPTIONS
to the same endpoint;
Date: Fri, 26 Mar 2021 01:02:26 GMT Content-Type: application/json Content-Length: 0 Connection: keep-alive x-amzn-RequestId: xxx Access-Control-Allow-Origin: * Access-Control-Allow-Headers: Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token x-amz-apigw-id: xxx Access-Control-Allow-Methods: DELETE,GET,OPTIONS,POST
https://stackoverflow.com/questions/66808890/static-s3-site-ajax-to-api-gateway-not-allowed-by-access-control-allow-origin March 26, 2021 at 07:18AM
没有评论:
发表评论