-2

I want my app to be example.com but the dashboard to be dashboard.example.com, how do I do that with one server running? I can easily spin up 2 express app and connect to the same db, and configure ngix config but I feel that is not a proper way to do things.

Any clue? I'm using express.js anyway.

Maria Jane
  • 2,353
  • 6
  • 23
  • 39

1 Answers1

0

You can try express-sudomain

var express = require('express');
var app = express();

var router = express.Router();

//api specific routes
router.get('/', function(req, res) {
   res.send('Welcome to our API!');
});

router.get('/users', function(req, res) {
    res.json([
        { name: "Brian" }
    ]);
});

app.use(subdomain('dashboard', router));
app.listen(3000);
Himani Agrawal
  • 1,242
  • 12
  • 14