本地测试跨域配置是否生效
参考网址:
https://blog.csdn.net/qq_41988504/article/details/103599189?utm_medium=distribute.pc_relevant.none-task-blog-OPENSEARCH-2.control&dist_request_id=61e22f9f-6c16-4e90-8f32-f2ad92a7f511&depth_1-utm_source=distribute.pc_relevant.none-task-blog-OPENSEARCH-2.control
测试模板
var token= "AD3BA267AD984966B3D2179C18FF44F0";
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://127.0.0.1:8080/test');
xhr.setRequestHeader("x-access-token",token);
xhr.send(null);
xhr.onload = function(e) {
var xhr = e.target;
console.log(xhr.responseText);
}
重点说明
没有token验证的可以去掉token
测试期间我们一般去除token
所以最终模板是
var xhr = new XMLHttpRequest();
xhr.open('GET', '测试的url地址');
xhr.send(null);
xhr.onload = function(e) {
var xhr = e.target;
console.log(xhr.responseText);
}