Vue 本地代理配置
vue 本地代理配置详情
解决方案
进入config/index.js 中 在proxyTable 后加入 要代理的路由
'/api': { //将www.exaple.com印射为/apis
target: 'http://ceshi.test.com/api', // 配置代理的地址
changeOrigin: true, //是否跨域
pathRewrite: {
'^/api': '' //需要rewrite的,
按照网上教程发现没有效果 还需要修改本地的host
mac 修改本地host 在 vim /etc/host
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
localhost:9528 http://ceshi.test.com/ ### 添加这条
~
重新npm run dev 后即可开启本地代理