Q:

NodeJs with ExpressJs API gets 404 when I publish it to server

This is driving me crazy.  I've created an app with NodeJs, ExpressJs and Angular.  I've got a client folder, which is Angular driven and a Server folder, where I have my ExpressJs REST Api.  
On my local system it uses the IP address and port and looks like this:
0.1.2.3:3000/getusers.  This works fine on my system. 
When I push it to the host I get a 404 error when calling the API.  The client is fine.  In the dev console I can see the same URL format: 2.2.2.3:3000/getusers. 
What am I missing here? 
This is the app.js config I'm using:
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 routes = require('./routes/index');
var users = require('./routes/users');
var getusers = require('./routes/getusers');
var test = require('./routes/test');

var app = express();

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

/**
 * Development Settings
 */
if (app.get('env') === 'development') {
    // This will change in production since we'll be using the dist folder
    app.use(express.static(path.join(__dirname, '../client')));
    // This covers serving up the index page
    app.use(express.static(path.join(__dirname, '../client/.tmp')));
    app.use(express.static(path.join(__dirname, '../client/app')));

    // Error Handling
    app.use(function(err, req, res, next) {
        res.status(err.status || 500);
        res.render('error', {
            message: err.message,
            error: err
        });
    });
}

/**
 * Production Settings
 */
if (app.get('env') === 'production') {

    // changes it to use the optimized version for production
    app.use(express.static(path.join(__dirname, '/dist')));

    // 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: {}
        });
    });
}

/**
 * Routes
 */
app.use('/getusers', getusers);
app.use('/test', test);

module.exports = app;

A:

Zeronone was right on his post.  This fixed it. 
Your error handler middleware should come at last before any other routes are registered.  Move the Routes to upper.  I guess you will get a 404 error even in development if you specify NODE_ENV=development environment. –  zeronone Jun 25 at 7:39 

