Skip to content

Commit ee448f9

Browse files
Feature: use newHost header if available
1 parent 412102f commit ee448f9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@ app.use('/favicon.ico', express.static('favicon.ico'));
1818

1919
// Points to API URL, based on platform (local or Heroku)
2020
app.get('/', (req, res) => {
21+
// Trick: if newHost header was present, use it
22+
let newUrl = req.get('newHost')
23+
if(typeof req.get('newHost') === 'undefined') {
24+
newUrl = req.get('host')
25+
}
26+
2127
res.json({
22-
'newUrl': req.get('newHost') + '/api',
23-
'defaultUrl': req.headers.host + '/api'
28+
'newUrl': newUrl + '/api'
2429
})
2530
})
2631

0 commit comments

Comments
 (0)