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

前端 未结 5 2117
挽巷
挽巷 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:57

    this helped me in java (expose the headers and then include in the allow headers). This will then show in your HttpResponse object:

    response.addHeader("Access-Control-Expose-Headers", "header1");
    response.addHeader("Access-Control-Expose-Headers", "header2");
        response.addHeader("Access-Control-Expose-Headers", "header3");
                    response.addHeader("Access-Control-Allow-Headers", "Origin, header1, header2, header3, X-Requested-With, Content-Type, Accept");
    

提交回复
热议问题