How to use http-proxy

Comprehensive http-proxy code examples:

How to use http-proxy.createProxy:

218
219
220
221
222
223
224
225
226
227
228
function start() {
  try {
    var proxyRules = new httpProxyRules({
      rules: router
    });
    var proxy = httpProxy.createProxy();


    httpServer = http.createServer(function (req, res) {
      try {
        logger.log.info(IDLOG, getProxyLog(req));

How to use http-proxy.createServer:

301
302
303
304
305
306
307
308
309
310

let world = await containerData(user);

if (world === undefined) res.redirect("/login");

const proxy = httpProxy.createServer({});

events.emit("registerProxy",
  {user: user, port: world.port}
);

How to use http-proxy.createProxyServer:

104
105
106
107
108
109
110
111
112
113
  contentType: this.contentType,
  handleError: typeof options.proxy !== 'string'
}))

if (typeof options.proxy === 'string') {
  var proxy = nm_httpProxy.createProxyServer({})
  before.push(function (req, res) {
    proxy.web(req, res, {
      target: options.proxy,
      changeOrigin: true