在过去的几年中,我第一次使用 AWS API Gateway 遇到了这个奇怪的阻塞错误,这可能会破坏生产环境:有一天,我的许多响应(并非全部)都丢失了Access-Control-Allow-Origin标头。在 Web UI 中,我也看到它们不存在。但它们仍然存在于导出的 Swagger 文件中。更重要的是 - 我无法设置任何值,'*'或者'https://example.com'我收到错误:
指定的映射表达式无效:验证结果:警告:[],错误:[指定的映射表达式参数无效:method.response.header.access-control-allow-origin]
这是昨天的(我没有改变任何东西来得到这个缺陷),看起来像阻止我们开发的 AWS 的可怕错误(没有 CORS 标头,主要产品不再可用)。现在我害怕将 AWS API Gateway 用于生产环境......
我尝试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"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4589 次 |
| 最近记录: |