L
L
legacy_js2021-09-21 12:39:30
Node.js
legacy_js, 2021-09-21 12:39:30

Why is the http-proxy library needed?

Please explain why this http-proxy library is needed .
Explain in simple words from their example

var http = require('http'),
    httpProxy = require('http-proxy');

var proxy = httpProxy.createProxyServer({});
 
var server = http.createServer(function(req, res) {
  // Зачем проксировать запрос
  proxy.web(req, res, { target: 'http://127.0.0.1:5050' });
});
 
console.log("listening on port 5050")
server.listen(5050);

What is it for to change the headers (like from their npm example)? After all, it can be done that way. I can’t understand why the client should change the request address?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2021-09-21
@legacy_js

To write your proxy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question