How does the frontend get cookie across domains?

clipboard.png

for example, the local domain name is aaa.com, but the interface uses bbb.com, so now the cookie sent back from the backend is also on the bbb.com. You can"t get the cookie directly from the local document.cookie. Is there a way to get it

?
Mar.11,2021

due to browser restrictions, the front end cannot get cross-domain cookie. You need to add a request header to the backend

Access-Control-Allow-Origin: http://aaa.com
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type, Set-Cookie, *
The domain in cookie in

bbb.com is not written, so aaa.com can get it, but it's not good to do so


backend solution or save the front end in session.


if necessary, store it in the browser cache. Cross-domain will bring more security problems


so that the request to access the b server is requested by the a server, and then returned by the a server to the front end

.

Menu