vue本地代理(解决跨域问题)
本文只针对axios+vue/cil3.0
axios配置:
const http = axios.create({ baseURL: process.env.NODE_ENV === 'production' ? 'http://www.xxxxx.com/': '', //这里是关键,配置你需要代理的地址 timeout: 10000, //withCredentials: true, headers: { 'Content-Type': 'application/json;charset=UTF-8', } })
vue.config.js配置
module.exports = { devServer:{ proxy:'http://www.xxxxx.com/' }, }