如何实现线上环境使用setting.host + '/api/sop/',本地dev请求localhost:3000呢?
const instance = axios.create({
baseURL: setting.host + '/api/sop/',
timeout: 20000,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
});
config
proxyTable: {
'/api': {
target: "http://127.0.0.1:3000",
changeOrigin: true,
pathRewrite: {
'^/api': ""
}
}
},
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
可以配置一个环境变量,通过判断环境变量确定使用哪一种配置