vue-cli使用axios跨域访问

在开发模式下使用axios进行跨域访问

	/*
	*在config中的index.js中修改proxyTable(只在开发测试中使用)
	*因为我的接口请求直接事http://xue.*****.com/***类型的,
	*所以以斜杠’/‘
	*/
	proxyTable: {
      '/':{
        target:'http://xue.*****.com',
        changeOrigin:true,
        pathRewrite:{
          "^/":'/'
        }
      }
    },

vue-cli打包之后线上模式,使用axios跨域访问,proxyTable则失效,得使用nginx反响代理

	/*
	*上线时候,地址要修改成线上地址,在使用nginx反向代理到后台接口地址http://xue.*****.com
	*/
	var instance=axios.create({
   		baseUrl:''http://song.*****.com"
   	})

猜你喜欢

转载自blog.csdn.net/weixin_43615360/article/details/86130592