colymore
colymore

Reputation: 12316

NodeJS with express dont response to request

I have a nodejs app made with express.

This is my server code:

var express = require('express');
var server = express();
var build = require('./build');
var logger = require('morgan');
var compress = require('compression');
server.use(logger);
server.use(compress);
server.use(require('method-override'));
server.use(require('body-parser'));
server.use(require('cookie-parser'));



var runBuild = function (params) {
    "use strict";

    var pushData = params.pushData;

    build({branch: pushData.branch},
        function (err, stdout, path) {

        });
};

server.post('/AndroidCIServer', function (req, res) {
    "use strict";


    res.send();
});

server.get('/', function(req, res) {
    res.render('index', { title: 'Express' });
});

server.listen(8089);

runBuild({
    pushData: {
        branch: 'master'
    }
});

I try to go to http://96.44.166.162:8089 but I don't get a response. I have a nginx server installed on port 80 and if I go to http://96.44.166.162/ it responds with the nginx index page.

(The IP is an external IP, in VPS)

What is happening?

Upvotes: 0

Views: 260

Answers (1)

mscdex
mscdex

Reputation: 106696

The modules need to be called so that they return the actual middleware:

server.use(logger());
server.use(compress());
server.use(require('method-override')());
server.use(require('body-parser')());
server.use(require('cookie-parser')());

This is done because it allows you to easily pass in configuration to the module so that the returned middleware is configured the way you want.

Upvotes: 2

Related Questions