From ee448f9ecd31859f095c04f3314308eca91d4e2f Mon Sep 17 00:00:00 2001 From: Fabio Beneditto Date: Wed, 2 Mar 2022 15:33:37 -0300 Subject: [PATCH] Feature: use newHost header if available --- index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 595a91d..46bf764 100644 --- a/index.js +++ b/index.js @@ -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' }) })