Amazon web services AWS API GW x-amazon-apigateway-integration响应状态代码regex不工作
我们在AWS网关中有一个API,它有一个连接到后端的端点。现在这个后端可以抛出200 ok、401 unauthorized、400或500。问题是,即使我们已经将401个错误映射到集成响应,我们仍然在postman中得到400个错误,而我们应该得到401个错误。我们的昂首阔步是这样的:Amazon web services AWS API GW x-amazon-apigateway-integration响应状态代码regex不工作,amazon-web-services,aws-api-gateway,Amazon Web Services,Aws Api Gateway,我们在AWS网关中有一个API,它有一个连接到后端的端点。现在这个后端可以抛出200 ok、401 unauthorized、400或500。问题是,即使我们已经将401个错误映射到集成响应,我们仍然在postman中得到400个错误,而我们应该得到401个错误。我们的昂首阔步是这样的: "x-amazon-apigateway-integration": { "responses": { "defau
"x-amazon-apigateway-integration": {
"responses": {
"default": {
"statusCode": "200",
"responseParameters": {
"method.response.header.Access-Control-Allow-Origin": "'*'",
}
},
"401": {
"statusCode": "401",
"responseParameters": {
"method.response.header.Access-Control-Allow-Origin": "'*'",
}
},
"4\\d{2}": {
"statusCode": "400",
"responseParameters": {
"method.response.header.Access-Control-Allow-Origin": "'*'",
"method.response.header.Cache-Control": "'no-cache,no-store'"
}
}
-
4\d{2}
401
5\d{2}
因此,我们用于4xx,4\d{2}的正则表达式似乎优先于我们的401响应。现在,我不知道这是否是一个问题,但当我查看AWS控制台时,响应的顺序如下:
"x-amazon-apigateway-integration": {
"responses": {
"default": {
"statusCode": "200",
"responseParameters": {
"method.response.header.Access-Control-Allow-Origin": "'*'",
}
},
"401": {
"statusCode": "401",
"responseParameters": {
"method.response.header.Access-Control-Allow-Origin": "'*'",
}
},
"4\\d{2}": {
"statusCode": "400",
"responseParameters": {
"method.response.header.Access-Control-Allow-Origin": "'*'",
"method.response.header.Cache-Control": "'no-cache,no-store'"
}
}
-
4\d{2}
401
5\d{2}
这可能是什么原因造成的?我是否可以重写4xx正则表达式,使其匹配除401之外的所有4xx代码