Skip to content

Commit

Permalink
feat: redirect from herokapp domain to nestrischamps.io
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeg committed Aug 13, 2024
1 parent fcae50d commit f05bce0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions modules/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,29 @@ app.set('view engine', 'ejs');
app.set('trust proxy', 1); // trust first proxy (i.e. heroku) -- needed to get req.protocol correctly

app.use(cors());

const pMap = {
http: 'https',
https: 'https',
ws: 'wss',
wss: 'wss',
};

// heroku redirector
app.use((req, res, next) => {
if (process.env.IS_LIVE_HEROKU) {
if (req.hostname === 'nestrischamps.herokuapp.com') {
res.redirect(
301,
`${pMap[req.protocol]}://nestrischamps.io${req.originalUrl}`
);
return;
}
}

next();
});

app.use(express.static('public'));
app.use(middlewares.sessionMiddleware);

Expand Down

0 comments on commit f05bce0

Please sign in to comment.