Change host protocol depending on website and localhost

If you're on localhost, your protocol (http vs https) takes
precedence. If not, the other website's takes precedence, because
otherwise you could end up being blocked by security
This commit is contained in:
Hippo 2020-05-10 23:03:14 +05:30
parent 7ad8f7b3f8
commit ee362e8954

View file

@ -39,7 +39,9 @@ app.use(renderer)
app.get('/', (req, res) => {
res.render('index', {
baseUrl: req.protocol + '://' + req.headers.host,
baseUrl: req.hostname.startsWith('localhost')
? req.protocol + '://' + req.headers.host
: '//' + req.hostname, // auto choose http or https
})
})