Http Response headers missing in chrome, but with Postman they show up

后端 未结 3 1087
别跟我提以往
别跟我提以往 2021-01-02 14:55

When calling my REST Service in Angular, there are no response headers.

Login method in Angular



        
3条回答
  •  一个人的身影
    2021-01-02 15:47

    By default CORS responses only expose these 6 headers :

    • Cache-Control
    • Content-Language
    • Content-Type
    • Expires
    • Last-Modified
    • Pragma

    To allow the scripts to access other headers sent by the sever, the server needs to send the Access-Control-Expose-Headers Header.

    The Access-Control-Expose-Headers response header indicates which headers can be exposed as part of the response by listing their names.

    eg: Access-Control-Expose-Headers: Authorization, X-Foobar

    You can tweak your web.xml file including this to allow the Authorization header to be accessed from the script that made the XHR:

    
      cors.exposedHeaders
      Authorizati‌​on
    
    

提交回复
热议问题