Reading response headers when using $http of Angularjs

后端 未结 2 1441
悲&欢浪女
悲&欢浪女 2020-11-27 15:51

I am using $http to make an api call which is sending some custom header like X-Foo. However I can\'t yet figure out how to read them. Inside the <

相关标签:
2条回答
  • 2020-11-27 16:05

    The custom headers will be visible in same domain. However, for the crossdomain situation, the server has to send Access-Control-Expose-Headers: X-Foo, ... header to make the custom headers visible.

    0 讨论(0)
  • 2020-11-27 16:21

    Spring 4.0+ provide @CrossOrigin annotation which has following parameters

    1. origins = list of Comma separated origin.
    2. exposedHeaders = list ofcomma separated count custom parameters.

    example

    @CrossOrigin(origins = "*", exposedHeaders ="X-Total-Count")
    
    0 讨论(0)
提交回复
热议问题