gpt4 book ai didi

aws-api-gateway - AWS API 网关 : error Invalid mapping expression parameter specified: method. response.header.access-control-allow-origin

转载 作者:行者123 更新时间:2023-12-04 12:02:49 38 4
gpt4 key购买 nike

在过去几年中,我第一次在使用 AWS API Gateway 时遇到了这个奇怪的阻塞错误,这会杀死生产环境:有一天,我的许多响应(不是全部)丢失了 Access-Control-Allow-Origin标题。在 Web UI 中,我也看到它们不存在。但它们仍然存在于导出的 Swagger 文件中。不仅如此 - 我无法为 '*' 设置任何值或 'https://example.com'我收到错误:

Invalid mapping expression specified: Validation Result: warnings : [], errors : [Invalid mapping expression parameter specified: method.response.header.access-control-allow-origin]



这是昨天的(我没有改变任何东西来得到这个缺陷),看起来像阻止我们开发的 AWS 的可怕错误(没有 CORS header ,主要产品不再可用)。现在我害怕将 AWS API Gateway 用于生产环境......

aws api gateway method execution error Invalid mapping expression parameter specified: method.response.header.access-control-allow-origin

我试图删除 Method Response 中的标题并通过相同的 Web UI 再次添加。

这是导出的 Swagger - 与屏幕截图中的相同部分。在这里你可以看到我的 method.response.header.Access-Control-Allow-Origin .所以在浏览器 UI 中和导出的文件是不一样的!
paths:
/lineupmaps:
get:
consumes:
- "application/json"
produces:
- "application/json"
responses:
200:
description: "200 response"
schema:
$ref: "#/definitions/Empty"
headers:
Access-Control-Allow-Origin:
type: "string"
security:
- cognito: []
x-amazon-apigateway-integration:
uri: "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:988646599334:function:getLineUpMap/invocations"
responses:
default:
statusCode: "200"
responseParameters:
method.response.header.access-control-allow-origin: "'https://happy-marketer.gms-ai.com'"
responseTemplates:
application/json: "$input.body"
passthroughBehavior: "when_no_match"
httpMethod: "POST"
requestTemplates:
application/json: "{\n \"specs\": $input.params('specs'),\n \"competitors\"\
: $input.params('competitors'),\n \"numberOfModels\": $input.params('numberOfModels')\n\
}"
contentHandling: "CONVERT_TO_TEXT"
type: "aws"
options:
consumes:
- "application/json"
produces:
- "application/json"
responses:
200:
description: "200 response"
schema:
$ref: "#/definitions/Empty"
headers:
Access-Control-Allow-Origin:
type: "string"
Access-Control-Max-Age:
type: "string"
Access-Control-Allow-Headers:
type: "string"
x-amazon-apigateway-integration:
responses:
default:
statusCode: "200"
responseParameters:
method.response.header.Access-Control-Max-Age: "'86400'"
method.response.header.Access-Control-Allow-Headers: "'Authorization'"
method.response.header.Access-Control-Allow-Origin: "'https://happy-marketer.gms-ai.com'"
passthroughBehavior: "when_no_match"
requestTemplates:
application/json: "{\"statusCode\": 200}"
type: "mock"

尝试导入导出的 Swagger,也有评论/删除 responseParameters块:仍然是同样的错误:
aws api gateway import swagger

最佳答案

谢谢nachary :帮助导入我的 Swagger 并移除了 method.response.header.access-control-allow-origin在一个端点的 GET 中...

关于aws-api-gateway - AWS API 网关 : error Invalid mapping expression parameter specified: method. response.header.access-control-allow-origin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60319964/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com