How can I have vhost with extension?
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'));
});