4.Vue跨域session问题解决

1.设置koa2服务器从本地代理转发
修改:项目/config/index.js-->dev中
proxyTable: {
'/api': {
target: 'http://localhost:3000',
changeOrigin: true,
pathRewrite: { //须要rewrite重写的, 若是在服务器端作了处理则能够不要这段
'^/api/': ''
}
}
},vue

//--------------------------------------------------
dev: {
env: require('./dev.env'),
port: 8080,
autoOpenBrowser: true,
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
'/api': {
target: 'http://localhost:3000',
changeOrigin: true,
pathRewrite: { //须要rewrite重写的, 若是在服务器端作了处理则能够不要这段
'^/api/': ''
}
}
},
//--------------------------------------------------ios

2.axios访问路径改成:
axGet('/api/hall/getRoomList',{},function(res){
alert(res.data);
},function(err){
alert(err);
});axios

3.必定要重启vue服务器api

相关文章
相关标签/搜索