Home > database >  why 401 response is empty in Chrome UI, but full in Postman?
why 401 response is empty in Chrome UI, but full in Postman?

Time:11-05

We have a React application using some Lambdas, API Gateway, CloudFront and Cognito with Bearer token for authorization. We noticed that in the app UI from Chrome, 401 (and other errors too) has empty response body therefore we are not able to catch the exception and handle it.

I changed the response body from api-gateway "Gateway Responses". I expected to receive the custom response in the UI but it was still empty. Postman works as expected.

axios code

CodePudding user response:

The problem was Chrome CORS issues and adding default CORS headers in gateway responses of API Gateway fixed everything. Also API Gateway can add the headers automatically.

  • Related