Created
May 15, 2018 20:11
-
-
Save nakedible-p/bac73a34eb3e3e2c637f80e14e839b7f to your computer and use it in GitHub Desktop.
HTTP to HTTPS redirect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('http').createServer((req, res) => { | |
const host = req.headers['x-forwarded-host'] || req.headers.host; | |
res.setHeader('Location', `https://${host}${req.url}`); | |
res.statusCode = 301; | |
res.end(); | |
}).listen(80); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment