How to use the createProxy function from http-proxy

Find comprehensive JavaScript http-proxy.createProxy code examples handpicked from public code repositorys.

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));
fork icon1
star icon0
watch icon0

10
11
12
13
14
15
16
17
18
19
20
21
22
const { DATABASE_PASSWORD, ENDPOINT_ZIP_MAX_MEGABYTES, JWT_EXPIRY_SECONDS, ENDPOINT_RESPONSE_MILLISECONDS, JWT_SECRET } = require('./constants');
const RateLimiter = require('./src/ratelimiter');


const rateLimiter = new RateLimiter();


const proxy = httpProxy.createProxy({ secure: false, proxyTimeout: ENDPOINT_RESPONSE_MILLISECONDS });


proxy.on('error', (err, req, res) => {
	res.writeHead(408, { 'Content-Type': 'text/plain' });
	res.end('Timeout\n');
fork icon0
star icon0
watch icon2

+ 3 other calls in file

5
6
7
8
9
10
11
12
13
14
15
		'/operator-mainnet/*': process.env.REACT_APP_MAINNET_VITASENSUS_SERVER_URL,
		'/gvite-testnet/*': process.env.REACT_APP_TEST_NETWORK,
		'/gvite-mainnet/*': process.env.REACT_APP_MAIN_NETWORK,
	},
});
const proxy = httpProxy.createProxy();


export default function handler(request, response) {
	try {
		var target = proxyRules.match(request);
fork icon0
star icon0
watch icon0