This method is deprecated and will likely be removed or changed in an upcoming release.
#There is no reliable, cross-platform way to automatically detect the external URL of a running Sails app (or any other Node app). Instead, configure your base URL explicitly and save it in custom configuration (e.g.
sails.config.custom.baseUrl
) that you can reference throughout the app. (This can then be overridden in production, staging, etc. as needed using environment-dependent configuration.)
Return a (possibly incorrect) best guess of the base URL for this app, based on a combination of user-supplied and default configuration values.
sails.getBaseUrl();
getBaseUrl()
constructs a URL string by inspecting various configuration values and defaults. For example, if sails.config.ssl.key
and sails.config.ssl.cert
both have values, the URL will start with https://
instead of http://
. If sails.config.explicitHost
is not undefined, its value will be used as the domain name, otherwise it will be localhost
. If sails.config.port
is not 80 or 443, its value will be appended to the URL as well.
This function does not accept any arguments.
Type:
http://localhost:1337
In an email template...
For more information, visit <a href="<%=sails.getBaseUrl()%>">our web site</a>.