Node.js post method is failing with 500 error
<p>I am new to node.js. I am developing node js application using VS 2015. Below is my server code (app.js)</p>

<p>In one of routes (trains.js) I defined a simple post method like below. Thing is it is working fine from localhost. But once I deploy to azure websites, POST method is throwing Internal server error.
Can some one help me with this? Please let me know if you need any further details.</p>

<pre><code>//Here is my app.js

var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var socketio   = require('socket.io');


var global = require('./routes/globals.js');

GLOBAL._ = require('lodash');
GLOBAL.KEY = 'xxxxxxxxxxxxxxxxxxxxxx';

var availability = require('./routes/availability');
var fare = require('./routes/fare');
var stations = require('./routes/stations');
var pnr = require('./routes/pnr');
var route = require('./routes/route');
var trains = require('./routes/trains');

var app = express();
app.socket = socketio();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cookieParser());
app.use(require('stylus').middleware(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'public')));

app.set('port', process.env.PORT || 3000);
app.use('/availability', availability);
app.use('/fare', fare);
app.use('/stations', stations);
app.use('/pnr', pnr);
app.use('/route', route);
app.use('/trains', trains);

// catch 404 and forward to error handler
app.use(function (req, res, next) {
    var err = new Error('Not Found');
    err.status = 404;
    next(err);
});

// error handlers

// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
    app.use(function (err, req, res, next) {
        res.status(err.status || 500);
        res.render('error', {
            message: err.message,
            error: err
        });
    });
}

// production error handler
// no stacktraces leaked to user
app.use(function (err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
        message: err.message,
        error: {}
    });
});

app.socket.on('connection', function (socket) {
    socket.on('message', function (msg) {
        console.log('Message Received: ', msg);
        socket.broadcast.emit('message', msg);
    });
});
global.io = app.socket;
module.exports = app;

//Here is my train.js
var express = require('express');
var http = require('http');
var router = express.Router();
var utils = require("./utils.js");
var global = require('./globals.js');

router.get('/', function (req, res) {
    var options = {
        host: 'www.xxxxxxx.com',
        path: '/test/xxxxxx/'
    };

    var parameters = {
        fscode : 'xxxx',
        tscode: 'xxxx',
        //date: '',
        //'class': '',
        //orderby: '',
        format: 'json',
        pbapikey: '9xxxxxxxxa'
    };

    options.path += utils.getQueryString(parameters);
    options.path += "pbapisign/" + utils.getHmacSHA1Signature(parameters);

    callback = function (response) {
        var data = "";
        response.on('data', function (chunk) {
            data += chunk;
        });
        response.on('end', function () {
            console.log(data);
            res.send(data + "&lt;h1&gt;" + utils.hello() + "&lt;/h1&gt;");
        });
    }

    http.request(options, callback).on('error', function (error) {
        console.log(error);
        res.status(400).send(error.Message)
    }).end();

});

router.post('/check', function (req, res) {
   // console.log('Request -', req);
   // console.log('Response -', res);
    var data = {
        request : "HELLO",
        response: "VAMSI"
    }
    global.io.sockets.emit('NEW_CONTACT', data);
    res.status(200).send('NEW DATA').end();

});



module.exports = router;
</code></pre>