Angularjs (1.2.10) $http.post throws 404 error while posting from phonegap to node.js server (cors request) -


i trying post comment nodejs server getting 404 error. have used cors module on server side handles cors request. using typescript.

cors module: https://github.com/troygoode/node-cors

var app = express(); app.use(cors()); (<any>app).options('*', cors()); // include before other routes app.use((<any>app).router); 

following endpoint code

app.post("/api/object/addcomment/:id", authenticatebearer(), (req, res) => {     var id = this.parseint(req.params.id);     var comment: string = req.body.commenttext;     if (this.isnullorundefined(id) && this.isnullorundefined(comment))         return this.sendinputerror("input empty.", res);      (new om.objectmanager()).addcomment(req.user.userid, id, comment, (err, commentid) => {         if (err) return this.sendinternalerror(err.message, res);         return res.json(commentid);     }); }); 

i calling above endpoint angularjs app,

myapp.config(function ($httpprovider) {     $httpprovider.defaults.usexdomain = true;     delete $httpprovider.defaults.headers.common['x-requested-with']; });  function addcomment(id, comment, callback) {     var url = client.config.resturl + "api/object/addcomment/" + id.tostring() + '?access_token=' + this.rootscope.loginuser.accesstoken;     this.$http.post(url, json.stringify({ commenttext: comment }))         .success((commentid, status) => {             callback(null, commentid);         })         .error((data, status) => {             callback(new error("an unexpected error occured while adding comment."), null);         }); } 

this code working in desktop environment. please see network log chrome, enter image description here

in phonegap, function call executes , comment added system $http.post giving 404 error (gets response in error callback). please see network log adb debugging tool (this works android 4.4.2), enter image description here

i struggling last 2 day. unable find solution. please me. in advance. sorry english.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -