title: Express app - Change base url
body: <p>I'm building a Q&amp;A app following <a href="http://engineering.paiza.io/entry/2016/03/10/115345" rel="noreferrer">this tutorial</a> and everything goes well, but I need to change the chance to change the base root where the app is being served via config files.</p>
  
  <p>Now the app is served in localhost:8080 and I need to be served over localhost:8080/qae (for example).</p>
  
  <p>I think the answer is near this piece of code:</p>
  
  <pre><code>// Setup server
  var app = express();
  var server = http.createServer(app);
  var socketio = require('socket.io')(server, {
    serveClient: config.env !== 'production',
    path: '/socket.io-client'
  });
  require('./config/socketio')(socketio);
  require('./config/express')(app);
  require('./routes')(app);
  
  
  // Start server
  function startServer() {
    app.angularFullstack = server.listen(config.port, config.ip, function() {
      console.log('Express server listening on %d, in %s mode '+config.ip, config.port, app.get('env'));
    });
  }
  
  setImmediate(startServer);
  </code></pre>
  
  <p>(from /server/app.js)</p>
  
  <p>But I can't figure it. Is it possible doing this in a simple way?</p>
  
  <p>////////EDIT////////</p>
  
  <p>I tried all the proposed solutions, but I'm doing something wrong and got errors. This is my routes.js in case it helps:</p>
  
  <pre><code>/**
   * Main application routes
   */
  
  'use strict';
  
  import errors from './components/errors';
  import path from 'path';
  
  export default function(app) {
    // Insert routes below
    app.use('/api/cpd', require('./api/cpd'));
    app.use('/api/categories', require('./api/category'));
    app.use('/api/terms', require('./api/term'));
    app.use('/api/qae', require('./api/qae'));
    app.use('/api/stats', require('./api/stat'));
    app.use('/api/tags', require('./api/tag'));
    app.use('/api/questions', require('./api/question'));
    app.use('/api/things', require('./api/thing'));
    app.use('/api/users', require('./api/user'));
  
    app.use('/auth', require('./auth'));
  
    app.use(function(req, res, next) {
      res.header("Access-Control-Allow-Origin", "*");
      res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
      next();
    });
  
  
    // All undefined asset or api routes should return a 404
    app.route('/:url(api|auth|components|app|bower_components|assets)/*')
     .get(errors[404]);
  
    // All other routes should redirect to the index.html
    app.route('/*')
      .get((req, res) =&gt; {
        res.sendFile(path.resolve(app.get('appPath') + '/index.html'));
      });
  }
  </code></pre>