Request header field is not allowed by Access-Control-Allow-Headers with $http

后端 未结 3 1473
广开言路
广开言路 2021-01-03 01:15

I\'m doing a POST to a service using Postman Chrome Extension, and I get the expected response.

But, when I do the same POST reque

3条回答
  •  半阙折子戏
    2021-01-03 02:00

    I believe configuring the Access-Control-Allow-Headers on the $httpProvider on the CLIENT will not work. I think the header needs to be configured on the server (as a response header). In a node-express application for instance, this could be done with a middleware (for example), putting something like this:

    res.header('*')
    

    or (more selectively) just the headers you need:

    res.header('Engaged-Auth-Token, Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With');
    

提交回复
热议问题