Skip to content

Commit

Permalink
Merge pull request #6 from FabioBeneditto/new-url-pattern
Browse files Browse the repository at this point in the history
Feature: use newHost header if available
  • Loading branch information
FabioBeneditto authored Mar 2, 2022
2 parents 412102f + ee448f9 commit d24b76d
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 d24b76d

Please sign in to comment.