1

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);
});
Andrew Olinevich
  • 61
  • 1
  • 1
  • 8

0 Answers0