Thoughts on a cross-domain

Cross-domain: As the name suggests, cross-port, domain names, are considered cross-domain protocol,

Usually in the background request, send http request, it is generally used axios with jQuery , this time sending a request by two, in the same domain that is not under the conditions of cross-domain browser automatically with cookie

 

 

Now that he has webpack proxy settings, it is to solve the problem of cross-domain, which means that if I want to request a local project http://baicu.com this domain name, then I have not cross-domain

Because the proxy he means is in the same domain forwarding a request, so when the proxy is not cross-domain, he is not in accordance with the cross-domain cookie handling or processing, the browser will automatically take on cookie

 

 

 

That's when you want to use axios time to bring cross-domain cookie, also set

 // `withCredentials` indicate whether to use credentials when cross-domain requests 
  withCredentials: false , // default

Like this

 

That native XMLHttpRequest when sending the request how it carries cookie

var xhr = new XMLHttpRequest();
xhr.setRequestHeader('Cookie', 'mycookie=cookie');

Above

WithCredentials heard may also be added in the request header which: true to achieve

 

Ha ha ha ha knowledge about cross-domain cookie with a welcome supplement

Guess you like

Origin www.cnblogs.com/lwwen/p/11577493.html