Doubt with subdomain express vhost

0

How can I have vhost with extension?

for example

HowItried:

app.use(vhost('api.*/portfolio',portfolioRouter));app.use(vhost('api.**/portfolio',portfolioRouter));

Butitdidnotwork.Iwonderifthisispossible,andifthat'show?

TheAPIisworkingcorrectly.

I'musingexpress

fullcode:

const express= require('express');
const vhost = require('vhost');
const bodyparser = require('body-parser');
const cors = require('cors');
const portfolioRouter = require('./api/router/portfolioRouter');
const app = express();

const public = express.Router();
const api = express.Router();

app.use(cors())
app.use(bodyparser.urlencoded({extended: true}))
app.use(bodyparser.json())

app.set('port', process.env.PORT || 3333);

app.use(vhost('api.*', api));


app.use(vhost('api.*.*/portfolio', portfolioRouter));

api.get('/', function( req, res){
    res.send("Welcome to my api");
});

app.use(express.static(__dirname+'/public_html'));

app.listen(app.get('port'), function(){
    console.log('iniciado em http://localhost:' + app.get('port'));
});
    
asked by anonymous 03.12.2018 / 18:28

0 answers