How to use the http-proxy/lib/http-proxy.createProxyServer 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 linksmart / border-gateway / bgw-http-proxy / index.js View on Github external
const config = require('./config');
const logger = require('../logger/log')(config.serviceName, config.logLevel);
const tracer = require('../tracer/trace').jaegerTrace(config.serviceName, config.enableDistributedTracing);
const opentracing = require('opentracing');
const cors = require('cors');
const app = require('express')();
const https = require('https');
const http = require('http');
const url = require("url");
const transform = require('transformer-proxy');
const agentHTTP = new http.Agent({});
const agentHTTPS = new https.Agent({});
const proxy = require('http-proxy/lib/http-proxy').createProxyServer({});
const {httpAuth, transformURI, bgwIfy, REQ_TYPES} = require('./utils');

app.use(cors());

app.use('/status', async (req, res) => {

    logger.log('debug', 'endpoint status called');
    res.status(200).json({status: "ok"});
});

app.use('/callback', async (req, res) => {

    let query = url.parse(req.url, true).query;
    logger.log('debug', 'endpoint callback called', {queryState: query && query.state});
    if (query && query.state) {