[英]AWS Api Gateway 403 error - CORS enabled from all origins
I have created a lambda function which is to be accessed via an API Gateway. 我创建了一个lambda函数,可以通过API网关进行访问。 However whenever a post request is made I get the following error
但是,每当发出发布请求时,都会出现以下错误
When I navigate to was console and look at API Gateway I have 当我导航到控制台并查看API Gateway时,
Finally my code (Angular2) does add the appropriate headers to the request by: 最后,我的代码(Angular2)确实通过以下方式将适当的标头添加到请求中:
var headers = new HttpHeaders();
headers.append('Content-Type', 'application/json');
this.http.post('https://execute-api.us-east-1.amazonaws.com/prod/LambdaFunction', this.email, { headers: headers })
.subscribe(data => console.log(data),
err => console.log(err));
Any idea how to fix this? 任何想法如何解决这个问题?
Looks like you are beating the wrong bush. 好像您在打错灌木丛。
You cannot enable CORS on a 403 since that is sent by APIGateway. 您不能在403上启用CORS,因为这是由APIGateway发送的。 The issue is you are trying to access a URL that is not accessible by APIGateway.
问题是您正在尝试访问APIGateway无法访问的URL。
If your URL is correct and POST worked, you will still receive 200 OK on a CORS call, but you will not be able to access the content received. 如果您的URL正确并且POST有效,那么在CORS呼叫中您仍然会收到200 OK,但是您将无法访问收到的内容。 (That is browser standard to avoid CORS call without valid permission on the return headers)
(这是浏览器的标准,以避免在没有返回头的有效许可的情况下进行CORS调用)
I was getting same error and I fixed the issue following path: 我遇到了同样的错误,并通过以下路径解决了该问题:
Try this first 先尝试一下
if this is not resolve from above use the below options as well. 如果无法从上方解决此问题,请使用以下选项。 In my case if resolve by below steps.
就我而言,请按以下步骤解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.