- 최신
- 최다 투표
- 가장 많은 댓글
Yes i have enabled CORS in API settings.
and when i upload html as static site - erros is the same
Thanks for your replies. I tried different combinations but still the same error. I'm a beginner, so maybe in the future I will approach the topic again.
At the moment I found a solution to upload a file using presign url
I made a few changes and now I can upload .pdf files with a predefined file name without any problems.
Thanks again for your commitment.
You are probably using API Gateway, have you enabled CORS?
Without this setting, access from index.html would result in an error.
https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors-console.html
There are few things here:
-
The error indicates that the origin is
null
. This happens when you try to open a file locally in the browser, for example by double clicking it or loading it withfile://
. You'll need to load the file from a local web server in order to test the upload functionality, and allowlocalhost
in the CORS settings in the API Gateway. There are many ways to run a local web server, and your IDE may also have this capability built-in. The mozilla developer's network has more information on this. -
If you have uploaded this page to a web server you should allow that domain in your CORS allow list.
-
You need to use
FormData()
to upload your file, because thebody
should have the binary contents of the file. Note in your postman screenshot thatbinary
is selected underBody
. See this example that usesfetch
to upload files.
관련 콘텐츠
- AWS 공식업데이트됨 일 년 전
- AWS 공식업데이트됨 9달 전
- AWS 공식업데이트됨 2년 전
- AWS 공식업데이트됨 4달 전
The following document describes common troubleshooting methods when CORS occurs with API Gateway. Please check once. https://repost.aws/knowledge-center/api-gateway-cors-errors Would it be possible to share a screenshot of the API Gateway CORS configuration screen? I was wondering if the required method (PUT) is allowed.