Angular 6 does not add X-XSRF-TOKEN header to http request

前端 未结 7 2047
忘了有多久
忘了有多久 2020-12-02 21:06

I\'ve read the docs and all the related questions on SO, but still Angular\'s XSRF mechanism isn\'t working for me: in no way I can make a POST request with the X-XSRF-TOKEN

相关标签:
7条回答
  • 2020-12-02 21:34

    The problem once again is Angular's poor documentation.

    The fact is, Angular will add the X-XSRF-TOKEN header only if the XSRF-TOKEN cookie was generated server-side with the following options:

    • Path = /
    • httpOnly = false (this is very important, and fully undocumented)

    Besides, the Angular app and the URL being called must reside on the same server.

    Reference: this Angular Github issue

    0 讨论(0)
提交回复
热议问题