cognito + API网关。获得状态401

时间:2017-03-30 09:28:07

标签: javascript node.js amazon-web-services aws-api-gateway amazon-cognito

我使用Express与API网关包装了API。 我正在使用Cognito Userpool来验证API网关。

当我使用Angular2 http服务访问该API时,返回正常值。 但是,当身份验证失败时,会出现以下错误。

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 401.

我正确设置了标头映射,但这次我收到了这个错误。

当我使用Postman访问它时,我得到以下结果。

{

 "message": "Unauthorized"

}

使用Angular2访问时,我也想要相同的结果。

这可能吗?

1 个答案:

答案 0 :(得分:0)

不幸的是,在某些错误情况下(例如401/403),即使配置正确,API网关也不会返回CORS标头。

我们意识到这对客户来说是一个痛点,并且正在研究解决方案,但是无法确定何时可以获得解决方案。