Reputation: 191
i am confuse currently, how i get base url in meanjs and have any method get url base on route, this idea is originated in framework php that have all similar function. Thank you very much
Upvotes: 1
Views: 199
Reputation: 6114
You can try use this code:
var url = require('url') ;
app.use(function (req, res) {
var hostname = req.headers.host; // hostname = 'localhost:12345'
var pathname = url.parse(req.url).pathname; // pathname = '/app'
console.log('http://' + hostname + pathname);
})
Or use
var fullUrl = req.protocol + '://' + req.get('host') + req.originalUrl;
Refference here
Upvotes: 5