1.开发环境,测试环境,生产环境 baseurl 是如何配置的?
var API_URL, RES_URL, publicPath;
if (process.env.NODE_ENV === 'dev') {
API_URL = '"https://client-local.baidu.com/app-client"';
RES_URL = '"https://res-local.baidu.com"';
publicPath = "https://client-local.baidu.com";
} else if (process.env.NODE_ENV === 'qa') {
API_URL = '"https://client-ts.baidu.com/app-client"';
RES_URL = '"https://res-ts.baidu.com"';
publicPath = "https://client-ts.baidu.com";
} else if (process.env.NODE_ENV === 'production') {
API_URL = '"https://client.baidu.com/app-client"';
RES_URL = '"https://res.baidu.com"';
publicPath = "https://client.baidu.com";
}
baseurl的地址可问后端要
2.项目中请求的时候怎么加上baseurl?
设置一个全局的拦截,在全局拦截中加入的
Vue.use(Resource);
Vue.http.options.emulateJSON = true;
Vue.http.options.credentials = true;
Vue.http.options.root = API_URL;
Vue.http.interceptors.push(function(request, next) {
next(function(response) {
//未登录被拦截
if (response.data.code === "000") {
localStorage.setItem('gotourl', window.location.href);//存到本地,登录后,再跳到此页面
window.location.href = '/login.html';
}
});
});
3.nginx配置的反向代理中,具体的运行机制到底是如何进行的?