【发布时间】:2019-03-08 02:27:16
【问题描述】:
我目前正在编写脚本,以便在将资源添加到 AWS API Gateway 上的 API 端点后以编程方式启用 CORS。在探索了几个小时的 put-integration-response 函数之后。我几乎取得了突破,但我遇到了一个错误:
An error occurred (BadRequestException) when calling the
PutIntegrationResponse operation: Invalid mapping expression specified:
Validation Result: warnings : [], errors : [No method response exists
for method.]
这是我用来启用 CORS 的脚本:
aws apigateway put-integration-response --rest-api-id XXXXX --resource
-id XXXX --http-method GET --status-code 200 --selection-pattern 200 --
response-parameters '{"method.reponse.header.Access-Control-Allow-
Origin": "'"'*'"'", "method.response.header.Access-Control-Allow-
Headers": "'"'integration.request.header.Authorization'"'"}'
我发现的奇怪之处是 AWS 文档似乎与当前版本的 aws-cli 过时了。我花了几个小时来解决我在调用 api 时遇到的一些基本问题。
将不胜感激任何想法。
干杯! 呐
【问题讨论】:
标签: amazon-web-services aws-lambda aws-api-gateway aws-serverless