Solution to the problem of ajax cross-domain with cookie

Generally, if you want to support ajax cross-domain with cookies, you need to add the following statement

    xhr.withCredentials = true; //Support sending cookies across domains

When coding specifically, this is the line:


Sometimes developers find that the request is OK in the past, but returns an error, the problem is as follows:


It is understood from the wrong literal meaning that the number of origin reported cannot be allowed to be empty!

However, this error is reported in Google's browser, and when using other browsers, this error does not appear!

It was finally confirmed that Google Chrome does not support it, and browsers under ie11 and individual browsers also do not support cross-domain cookies!


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324655798&siteId=291194637