title: Run multiple Node.js apps on the same server
body: <p>I want to run multiple Node js apps on the same server, and so far I made some progress checking solutions for similar questions here (links below). Let's say I have 2 apps, each serving some html file, and I'd like to access each by visiting
  <a href="https://example.com/app1" rel="nofollow noreferrer">https://example.com/app1</a> and
  <a href="https://example.com/app2" rel="nofollow noreferrer">https://example.com/app2</a><br />
  So far, I have my main app, and my approach was to call this app which will then redirect a client to one of these 2 apps.<br />
  My main app looks like this:</p>
  <pre><code>const express = require('express');
  const app = express();
  
  app
    .use('/app1', require('./app1/index.js'))
    .use('/app2', require('./app2/index.js'))
    .listen(80);
  
  </code></pre>
  <p>Each of my two sub-apps (app1 and app2) looks like this</p>
  <pre><code>const express = require('express');
  const bodyParser = require('body-parser');
  const routes = require('./routes/api');
  const mongoose = require('mongoose');
  require('dotenv/config');
  
  const app = express();
  
  mongoose.connect(
      process.env.DB_CONNECTION,
      { useNewUrlParser: true, useUnifiedTopology: true }, () =&gt;
      console.log('Connected to DB')
  );
  mongoose.Promise = global.Promise;
  
  app.use(express.static('public'));
  app.use(bodyParser.json());
  
  app.use('/', routes); 
  
  app.use(function (err, req, res, next) {
      res.status(422).send({ error: err.message })
  });
  </code></pre>
  <p>The issue is that I don't get anything after deploying these apps and visiting e.g. <a href="https://example.com/app1" rel="nofollow noreferrer">https://example.com/app1</a><br />
  I'm super new in all this so there is likely a beginner's mistake in here. Can anyone help?</p>
  <p>Related questions <a href="https://stackoverflow.com/questions/8514106/how-to-mount-express-js-sub-apps">How to mount express.js sub-apps?</a> and <a href="https://stackoverflow.com/questions/11225983/running-multiple-node-express-apps-on-same-port">Running multiple Node (Express) apps on same port</a></p>