ionic 页面 微信浏览器遇到的坑
公司的微信公众号一部分页面是用AngularJS+Ioinc开发,发现在本地浏览器测试的时候都没问题,传到服务器在微信公众号下跑就出问题来,经查是:
index-tab页面 406 not accessable http请求头问题
$httpProvider.interceptors.push(function() {
return {
"request": function(config) {
//console.log(config.url);
if (config.url && config.url.lastIndexOf(".html") > 1) {
config.headers["Content-Type"] = "text/html; charset=utf=8";
config.headers["Accept"] = "*/*";
}
if (window.sessionStorage.getItem("sessionId")) {
config.headers['sessionId'] = window.sessionStorage.getItem("sessionId");
}
return config;
},
"response": function(res) {
if (res.config.url && !res.config.url.lastIndexOf(".html")) {
// console.log(res.data);
/*if (res.data.errorCode == '550') {
window.location.href = "#/weblogin";
}*/
}
return res;
}
}
});
上面的sessionStorage不是必须配置。