Created
April 18, 2018 18:57
-
-
Save reu/6168f8f37111691d50a8a25377206e35 to your computer and use it in GitHub Desktop.
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
const http = require("http"); | |
const path = require("path"); | |
const target = process.env.TARGET; // ex: google.com | |
const port = process.env.PORT || 80; | |
http | |
.createServer(({ url, headers }, res) => { | |
const protocol = headers["x-forwarded-proto"] || "http"; | |
res.writeHead(308, { Location: `${protocol}://${path.join(target, url)}` }); | |
res.end(); | |
}) | |
.listen(port); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment