I trying to get current web address using sails.js.
I tried the following:
req.param(\'host\') and req.param(\'X-Forwarded-Protocol\')
On sails 0.10.x, you could do this:
//inside controller action
var baseURL = req.protocol + '://' + req.host;
req.protocol
will give you 'http' or 'https' (or whatever application protocol). req.host
will be the host's header, e.g. 'sub.domain.com'
As noted in a comment above, sails.getBaseURL()
or any of it's variants will usually return localhost, even in a production environment.