Angular2 : X-XSRF-TOKEN is not allowed by Access-Control-Allow-Headers

前端 未结 5 2120
挽巷
挽巷 2021-02-13 14:30

I am struggling with this issue today as I am implementing a cross-site API call. The worst thing is it works well from my local environment but once on heroku, it fails with th

5条回答
  •  生来不讨喜
    2021-02-13 14:54

    In my case I had to add the 'x-xsrf-token' value to 'Access-Control-Allow-Headers' header:

    header('Access-Control-Allow-Headers: Content-Type, x-xsrf-token')
    

    see AngularJS: POST Data to External REST API

提交回复
热议问题