1. 程式人生 > >4.Vue跨域session問題解決

4.Vue跨域session問題解決

-- icp change 服務 get 做了 oom vue ubd

1.設置koa2服務器從本地代理轉發
修改:項目/config/index.js-->dev中
proxyTable: {
‘/api‘: {
target: ‘http://localhost:3000‘,
changeOrigin: true,
pathRewrite: { //需要rewrite重寫的, 如果在服務器端做了處理則可以不要這段
‘^/api/‘: ‘‘
}
}
},

//--------------------------------------------------
dev: {
env: require(‘./dev.env‘),
port: 8080,
autoOpenBrowser: true,
assetsSubDirectory: ‘static‘,
assetsPublicPath: ‘/‘,
proxyTable: {
‘/api‘: {
target: ‘http://localhost:3000‘,
changeOrigin: true,
pathRewrite: { //需要rewrite重寫的, 如果在服務器端做了處理則可以不要這段
‘^/api/‘: ‘‘
}
}
},
//--------------------------------------------------

2.axios訪問路徑改為:
axGet(‘/api/hall/getRoomList‘,{},function(res){
alert(res.data);
},function(err){
alert(err);
});

3.一定要重啟vue服務器

4.Vue跨域session問題解決