How to use the http-proxy.prototype function in http-proxy

To help you get started, we’ve selected a few http-proxy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LogMeIn / logmein-linux-host / reverse-proxy / app.js View on Github external
#!/usr/bin/env node

var http = require('http'),
    httpProxy = require('http-proxy'),
    express = require('express'),
    cookieParser = require('cookie-parser'),
    crypto = require('crypto'),
    path = require('path'),
    tcpPortUsed = require('tcp-port-used');

httpProxy.prototype.onError = function (err) {
  console.error("Error during connection:", err.code);
}

var app = express();
var http = require('http');

app.use(cookieParser());

app.use(function (req, res, next) {
  var rasid = req.cookies['RASID'];
  if (rasid === undefined) {
    console.log("Generating RASID");
    res.cookie("RASID", crypto.randomBytes(40).toString("hex"));
  }
  next();
});