Skip to content

Instantly share code, notes, and snippets.

@onxssis
Created May 15, 2018 11:21
Show Gist options
  • Save onxssis/59a071d4fd6cbf9b89d3a43ea0ce9611 to your computer and use it in GitHub Desktop.
Save onxssis/59a071d4fd6cbf9b89d3a43ea0ce9611 to your computer and use it in GitHub Desktop.
// add this to hooks.js in hooks.after.providersBooted fn
View.global('absoluteUrl', function (path) {
const req = this.resolve('request')
let baseUrl = req.secure() ? 'https://' : 'http://'
baseUrl += req.headers().host + '/'
if (typeof path !== 'undefined') {
path = (path.substring(0, 1) === '/')
? path.substring(1)
: path
return baseUrl + path
}
return baseUrl
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment