我的服务在localhost:3000,现在点击预留启动的是localhost:7456。在项目里面将url设置为:let url = “localhost:3000/login”;会返回错误
Login.js:33 XMLHttpRequest cannot load localhost:3000/login. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
以下是我的代码:
doReq:function(){
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status < 400)) {
var response = xhr.responseText;
console.log(response);
}
};
let url = "login";
xhr.open("GET", url, true);
xhr.send();
},
应该是跨域的问题,我将3000的服务器和chrome都添加了跨域的,但还是没用。是7456服务器的问题吗?如果是,要怎么修改???
附上我尝试过的方法
1: 如何解决跨域问题:==无效==里面主要是说使用cors插件。
2: 修改chrome启动项==无效==