diff --git a/proxy/proxy.js b/proxy/proxy.js index 29e86b98dad725b6c34826c1f649bd2f8958bb1a..a6556ddf4106b1bdaf790af565ec03b826641556 100644 --- a/proxy/proxy.js +++ b/proxy/proxy.js @@ -1,10 +1,26 @@ const http = require('http'); -const PORT = 3000; +const PORT = 8080; const requestListener = (req,res)=>{ - res.writeHead(200); + const options = { + hostname:'localhost', + port:3000, + path:'/' + }; + const get = http.get(options,response=>{ + console.log(`statusCode: ${response.statusCode}`); + let buffer=""; + response.on('data',d=>{buffer+=d}); + response.on('error',err=>{console.log(`error:${err}`)}); + response.on('end',()=>{ + res.setHeader("Content-Type", "text/html"); + res.writeHead(200); + res.end(buffer); + }); + }) + // res.writeHead(200); console.log(req.headers); - res.end("hello"); + // res.end("hello"); } const server = http.createServer(requestListener);