let config = { baseURL: "http://api.ksw******n:6699/go***/", // 公网的接口地址 headers: { ‘Content-Type‘: "application/json;charset=utf-8" } // timeout: 5000, // Timeout // withCredentials: true, // Check cross-site Access-Control };
_axios.interceptors.request.use( function (config) { console.log(window.location.host); if(window.location.host === ‘170.***.0.**:18*00‘){ // 判断如果是从社会面网访问(客户那边局域网) config.baseURL = ‘http://170.***.0.**:8001/gongan/‘ // 就走内网的接口,接口地址更换为这个 }* return config; },
原文:https://www.cnblogs.com/jane-panyiyun/p/14626427.html