new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
hot: true,
historyApiFallback: true,
stats: { colors: true },
proxy:{
'/orxxxxxxx': {
target: 'https://api.xxxxxx/2.0',
secure: false
}
}
}).listen(3000, 'localhost', function (err, result) {
if (err) {
console.log(err);
}
console.log('server start');
});
跨域请求总会报这样的错误
XMLHttpRequest cannot load https://api.xxxxxxxx/2.0/orxx... No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.
求大神帮忙
补充
我的ajax这样写的
$.ajax({
url:'https://api.xxxxxxx/2.0/orxxxxxxxxx/xxxx',
type: 'POST',
dataType: 'json',
data: values,
success: function(map){
var login = map.error;
if (login='') {
window.location.href="/dist/about/index.html";
}
}
})
你的请求没有带上cors的参数
或者后台不允许跨域
反正跟webpack proxy没关系
更新一下,
你jquery ajax跨域没打开