ionic 頁面 微信瀏覽器遇到的坑
公司的微信公眾號一部分頁面是用AngularJS+Ioinc開發,發現在本地瀏覽器測試的時候都沒問題,傳到服務器在微信公眾號下跑就出問題來,經查是:
index-tab頁面 406 not accessable http請求頭問題
1 $httpProvider.interceptors.push(function() { 2 return { 3 "request": function(config) { 4 //console.log(config.url); 5 if (config.url && config.url.lastIndexOf(".html") > 1) { 6 config.headers["Content-Type"] = "text/html; charset=utf=8"; 7 config.headers["Accept"] = "*/*"; 8 } 9 if (window.sessionStorage.getItem("sessionId")) { 10 config.headers['sessionId'] = window.sessionStorage.getItem("sessionId"); 11 } 12 return config; 13 }, 14 "response": function(res) { 15 if (res.config.url && !res.config.url.lastIndexOf(".html")) { 16 // console.log(res.data); 17 /*if (res.data.errorCode == '550') { 18 window.location.href = "#/weblogin"; 19 }*/ 20 } 21 return res; 22 } 23 } 24 });
上面的sessionStorage不是必須配置。