getting CORS error while using AWS api gateway - amazon-web-services

I have created a API from this AWS tutorial https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-upload-image-s3/#:~:text=Upload%20an%20image%20file%20to%20S3%20by%20invoking%20your%20API,API%20in%20Amazon%20API%20Gateway.
This API Uploads Images to s3 directly from API Gateway I have enabled CORS from API gateway and while using postman i am getting Access-Control-Allow-Origin to * but while using it with react on local host I am getting CORS error

Related

How to avoid the CORS error from an API created in AWS API Gateway?

I have created a React Application to upload a file to the S3 bucket. To do this, I have created a PUT API from the AWS API Gateway and the API is working well in the POSTMAN. The problem is, when I call the API from my React Application locally (http://localhost:3000), I'm getting a CORS error from the PUT request and a 403 error from the OPTIONS request (Preflight). How can I solve this?
Here is the bucket policy
Here is the Bucket CORS Policy
Here are the Enable CORS settings of the API in the API Gateway
The Output
Your bucket policy does not allow putObject method. CORS can be seen when some unrelated errors happen. I encourage you to enable INFO logging for API Gateway and check what exactly happens. Share the logs and it will be easier to tell.
To enable INFO logging for API Gateway, go to API -> Settings -> add CloudWatch log role ARN which would have permission to write into cloudwatch logs. Then enable full INFO logs. You will find logs inside CloudWatch logs

AWS CORS HTTP API Preflight request not working

The AWS HTTP API is configured as shown below.
AWS API
The CORS Preflight request is still throwing the following error:
Preflight response from the Browser
CORS headers is missing in the pre flight. I have tried to configure it in different without luck.
And I do not have the options configured in the routes of the HTTP API.
Finally I was able to solve it by removing the CORS configuration and adding a route OPTIONS with a lambda integration to return the relevant CORS headers.
Unlike the REST API aws API gateway the OPTIONS do not seems to have a mock integration.

AWS S3 is not connecting with API Gateway due to CORS errors

I'm hosting my react application's build on S3 bucket, and I also have a lambda function running for my API using AWS's API-Gateway.
I'm trying to send a post/get requests from my static website to this API gateway (which is also using API KEY to authorize) and I'm getting CORS error for no reason.
I've tried to debug it using postman and everything works great.
I've added x-api-key to the default headers of axios in my application and inserted the key as requested.
Is there a problem using S3 for hosting a static website that uses POST/GET requests?
btw: I've allowed CORS in my API-gateway (as I said, it works on Postman)
Thanks!

API Gateway Invoke Endpoint works fine; Cloudfront returns 403

I've set up an AWS API Gateway proxy endpoint to a lambda function and deployed it to a stage called auth. The Invoke URL found on the API Gateway dashboard works just fine and executes my lambda.
However, I've created a Cloudfront distribution that I want to map to API Gateway. I set the Origin to the API Gateway URL and configured a behavior to forward /auth/* to the API Gateway origin:
Origin Settings:
Behavior Settings:
However, this doesn't work. I get a 403 Forbidden message from Cloudfront:
This is extremely confusing for me because I have an almost identical set up on another AWS account that works just fine. Does anyone know what the problem might be?

Is there any way to to send large file through API Gateway?

I'm working on the application that will receive files from users and then upload to Amazon S3. The application is accessed using API Gateway. The service API Gateway has limits for payload size for both WebSocket and REST APIs. Is there any way to access my service from the Internet through API Gateway?
API gateway is not intended to be data transfer gateway, but lightweight API definition layer.
The most suitable approach is to generate temporary pre-signed upload URL and redirect (30X) requests there. API Gateway should define an endpoint, calling lambda function which generates pre-signed S3 URL and redirect post request there (after user's authentication of course).
Please refer an example of app with API Gateway and pre-signed S3 URLs to upload files
API documentation for generating pre-signed S3 URLs in Python, AWS CLI and even Go-lang