Why does a cross-domain angularjs $http.post request fail when a XMLHttpRequest succeeds?

前端 未结 6 411
情歌与酒
情歌与酒 2021-02-01 10:32

I am trying to exercise the Trello API with an application key and token from an angular (version 1.0.5) webapp. The server seems correctly configured to handle CORS. A test req

6条回答
  •  失恋的感觉
    2021-02-01 11:31

    The 'content-type' header is not accepted by the server and is added by default for Angular $http POST request (see $http doc). You can try to remove it from your $http config. Inject $httpProvider in your controller, then this might work:

    delete $httpProvider.defaults.headers.post['Content-type']
    

    You might have to try with 'content-type' also, I'm not sure of the case to use.

提交回复
热议问题