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

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -