【发布时间】:2020-04-30 16:53:10
【问题描述】:
亚马逊发布了通过 API 网关创建 HTTP API 的功能。在他们的网站上,他们描述可以通过 AWS CLI 创建 HTTP API:https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-examples.html#http-api-examples.cli.quick-create。
举例:
aws apigatewayv2 create-api --name my-api --protocol-type HTTP --target arn:aws:lambda:us-east-2:123456789012:function:function-name
对于 REST API,我知道可以通过 AWS CLI 更新 CORS 策略。我想知道是否也可以通过 AWS CLI 更改/创建 HTTP API 的 CORS 策略?
我想使用 HTTP API,因为它可以节省很多钱!
提前致谢!
【问题讨论】:
-
您当然可以通过 CLI 更新 CORS 策略。我已经能够使用
aws apigatewayv2 update-api --api-id API-ID --cors-configuration AllowOrigins="*"成功更新它。我的主要问题是 API 网关似乎没有尊重此政策,因为我所有的飞行前选项请求都收到 500 错误。
标签: amazon-web-services api aws-api-gateway api-gateway