Requirement: The front end of the company needs to pass the token after login to the backstage through the way of cookie. (including the ability to modify cookies).
Post the Code:
We are through the MUI Ajax request, carefully read the text of the request in the head, found backstage callback a set-cookie. Get saved by Document.cookie.
Our Ajax is encapsulated, first before the request to set a cookie, that is, before the cookie, the second set xhrfields this parameter does not know what is, you can first look at the introduction
Or simply say that the request header will automatically bring a cookie when this parameter is set. (This is how the code with the cookie in the request header)
Second, how to modify cookies
Very simple, in the back of the Set-cookie in the back of the onlyhttp can not, just need to reset the cookie before the request, you can.
Or we can force set the cookie, need to set in the request header, is the header parameter inside, can only use Set-cookie, if using the cookie source code will error. Because it is not allowed to set cookies for individuals
This also allows you to set the parameters we want in the request header.
Ajax Request Header Cookie problem