Can't perform POST request in Android browser with AngularJS

十年热恋 提交于 2019-12-20 04:23:13

问题


I've got a angular application that displays records, and gives the user the ability to add records.

Everything works perfect on desktop or iOS devices, but on android devices, the POST method fails(403 - forbidden).

this is the code in my service:

obj.getRecords = function() {
    return $http.get(serviceBase + 'records');
};
obj.getRecord = function(id) {
    return $http.get(serviceBase + 'record/' + id);
};
obj.saveRecord = function(record) {
    return $http.post(serviceBase + 'record', record);
};

Anyone experienced with this problem?


回答1:


$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";

might fix your problem.

Reference: Angular docs




回答2:


I could imagine that it could have to do with an apple touch icon that is integrated into your site. I had it once that it missing (even if iPhones worked!) caused redirection to another site with another session id. This also caused a 403. It's just an idea though. It seems that the Android browser has some other way of retrieving the touch icon which is the error's cause.



来源:https://stackoverflow.com/questions/26385301/cant-perform-post-request-in-android-browser-with-angularjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!