Skip to content
This repository was archived by the owner on Jun 10, 2019. It is now read-only.

Commit 9ef5a55

Browse files
tskuserickr
authored andcommitted
Add proxy support for HTTP->HTTPs redirect (#73)
1 parent 06d7438 commit 9ef5a55

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

server.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ const path = require('path');
44

55
const app = express();
66

7+
app.enable('trust proxy');
8+
79
app.use((req, res, next) => {
8-
if (!req.secure) {
10+
if (req.headers['x-forwarded-proto'] !== 'https') {
911
return res.redirect(`https://${req.headers.host}${req.url}`);
1012
}
1113
return next();

0 commit comments

Comments
 (0)