Vhost + express why doesn't work?

224 views Asked by At

I try to configure my node.js + express application for creation multiple domain server. This is my code, but unfortunately it's not working. Please explain me, what is wrong in this code?

const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const vhost = require('vhost')


const app = express();
app.use(bodyParser.json());

// Port
const port = 8081;

app.use('/', express.static(path.join(__dirname, 'public')));

app.use(vhost('*.localhost:8081', function(req, res, next){
  res.send('Ok, its work.');
})); 

app.listen(port, function(){
  console.log('App is running on port '+ port);
});

0

There are 0 answers