How to get the base or root url in sailsjs?

express, node.js, root, sails.js, url

Solution

Sails.js is based on Express, so from within your action you can do the following:

var protocol = req.connection.encrypted?'https':'http';
var baseUrl = protocol + '://' + req.headers.host + '/';

Problem

Is there a sails way of extracting the root or base url of an app? I basically need this for sending activation emails with links.

Original source

Related problems