Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services AWS API GW x-amazon-apigateway-integration响应状态代码regex不工作_Amazon Web Services_Aws Api Gateway - Fatal编程技术网

Amazon web services AWS API GW x-amazon-apigateway-integration响应状态代码regex不工作

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

我们在AWS网关中有一个API,它有一个连接到后端的端点。现在这个后端可以抛出200 ok、401 unauthorized、400或500。问题是,即使我们已经将401个错误映射到集成响应,我们仍然在postman中得到400个错误,而我们应该得到401个错误。我们的昂首阔步是这样的:

"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代码