Skip to content

Commit

Permalink
Feature: use newHost header if available
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioBeneditto committed Mar 2, 2022
1 parent 412102f commit ee448f9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ app.use('/favicon.ico', express.static('favicon.ico'));

// Points to API URL, based on platform (local or Heroku)
app.get('/', (req, res) => {
// Trick: if newHost header was present, use it
let newUrl = req.get('newHost')
if(typeof req.get('newHost') === 'undefined') {
newUrl = req.get('host')
}

res.json({
'newUrl': req.get('newHost') + '/api',
'defaultUrl': req.headers.host + '/api'
'newUrl': newUrl + '/api'
})
})

Expand Down

0 comments on commit ee448f9

Please sign in to comment.