Node.js on Openshift gives error 400 but works properly on local machine
<p>My <code>Node + MongoDB</code> based REST API works fine on local <code>Node</code> server and returns the correct output. But <code>Express</code>(probably!) returns error <code>400 Bad Request</code> when deployed on Openshift.
Any idea how I might debug the app? I tried putting some <code>console.log</code> statements in the offending method but even those were not called.</p>

<p>BTW, some sample code:</p>

<p>app.js:</p>

<pre><code>var express = require('express');
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
var app = express();

var userController = require('./Controllers/user');
var authController = require('./Controllers/auth');
mongoose.connect(process.env.OPENSHIFT_MONGODB_DB_URL + 'dbname');
app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());
app.use(function(req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With , content-type, Authorization ,x-access-token ,' +
    'x-auth-email ,x-auth-password');
next();
});

app.post('/signin',authController.authorize,userController.signin);
</code></pre>

<p>controllers/auth.js:</p>

<pre><code>var passport = require('passport');
var User = require('../Models/user');
var LocalStrategy = require('passport-local').Strategy;

passport.use(new LocalStrategy(function(email,password,callback) {
console.log('passport called');
User.findOne({email:email},function(err, user){
    console.log('email at passport: ' + email);
    if(err){
       return callback(err);}


   if(!user){return callback(null,false);}

    user.matchPassword(password,function(err,isMatch){
        if(err){return callback(err);}

        if(!isMatch){return callback(null,false);}

        console.log('isMatch: ' + isMatch);
        return callback(null,user);
      });
    });
 }));

 exports.authorize = passport.authenticate('local', { session : false });
</code></pre>

<p>controllers/user.js:</p>

<pre><code> var User = require('../Models/user');
 var jwt = require('jsonwebtoken');
 exports.signin = signin= function (req,res){
User.findOne({email:req.body.email},function(err, user){
    if(err){res.send(err);}


    console.log(user);
        user.token = jwt.sign(user.password, 'SECRET_KEY');
        user.save(function (err,user) {
            if (err) {
                res.send(err);
            }
            res.json({email:user.email,token:user.token});
        })
});
};
</code></pre>

<p>Calling the <code>signin</code> route with POST in Postman returns expected data in json in Local server but returns <code>HTTP 400 Bad Request</code> on deploying on Openshift. I even tried downgrading <code>express</code> to the version on Openshift but the issue remains the same.</p>