Created
December 29, 2019 01:06
-
-
Save alanwei43/fef15b7f6c0f0b2dc7ec568e94bb5465 to your computer and use it in GitHub Desktop.
Node HTTP pipe
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"), | |
url = require("url"); | |
http.createServer((proxyReq, proxyRes) => { | |
console.log(proxyReq.url); | |
const options = url.parse(proxyReq.url); | |
const svr = http.request(options, svrRes => { | |
svrRes.pipe(proxyRes, { end: true }); | |
}); | |
proxyReq.pipe(svr, { | |
end: true | |
}); | |
}).listen(3003); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment