1.找到項目中config->index.js,然后找到配置文件中的proxyTable如下圖:
proxyTable: {
'/api': {
target: 'http://localhost:8090/', //你要跨域的網址 比如 'http://news.baidu.com',
// secure: true, // 如果是https接口,需要配置這個參數
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
}
},
2.把項目中調用的接口的 協議://域名:端口號換成/api
3.重啟一下服務