Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the base or root url in sailsjs?

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.

like image 371
Carlos Feliciano Barba Avatar asked Feb 03 '26 07:02

Carlos Feliciano Barba


1 Answers

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 + '/';
like image 199
bredikhin Avatar answered Feb 04 '26 23:02

bredikhin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!