const proxy = httpProxy.createProxy() this[kServer].on('request', onRequest(proxy.web.bind(proxy))) this[kServer].on('upgrade', onRequest(proxy.ws.bind(proxy)))
var proxyMiddleware = function(req, res, next) { if (req.url.indexOf('api') != -1) { proxy.web(req, res); } else { next(); } }
app.all('/db/*', function (req, res) { proxy.web(req, res, { target: 'https://glowing-carpet-4534.firebaseio.com/' }); });
// Create http server that leverages reverse proxy instance // and proxy rules to proxy requests to different targets http.createServer((req, res) => { logger.info(`${req.method} ${req.url}`); const target = proxyRules.match(req); if (target) { return proxy.web(req, res, { target }); } res.writeHead(500, { 'Content-Type': 'text/plain' }); res.end('The request url and path did not match any of the listed rules!'); return null; }).listen(configuration.web_server.port);
http.createServer(function (req, res) { logger.info(`Incoming request: ${req.method} ${req.url}`) logger.debug(req) try { filterRequest(req, argv) return proxy.web(req, res, { target: argv.target }) } catch (err) { logger.error(err, 'Request rejected') res.writeHead(400, { 'Content-Type': 'application/json' }) return res.end(JSON.stringify({ error: 'Request rejected' })) } })
http.createServer(function(req, res) { if (options.proxyAuth && !reqIsAuthenticated(req, options.proxyAuth)) { res.writeHead(407); return res.end(); } var target = _.omit(url.parse(req.url), 'path'); proxy.web(req, res, { target: target }); }).listen(port, host)
process.nextTick(function () { app.use(function (req, res) { proxy.web(req, res, {target: host}); }); });
http .createServer(function(req, res) { let remote = HOST1; if (req.url.startsWith("/waittime")) { remote = HOST2; } proxy.web(req, res, { target: remote, secure: false }); }) .listen(process.env.PORT || 3000);
app.use('/api', (req, res) => { proxy.web(req, res); });
app.all('/socket.io*', function (req, res) { proxy.web(req, res, { target: 'http://127.0.0.1:3001' }); });
app.all('/build/*', function (req, res) { proxy.web(req, res, { target: 'http://127.0.0.1:3001' }); });
// Any requests to localhost:3000/build is proxied // to webpack-dev-server app.all('/build/*', function (req, res) { proxy.web(req, res, { target: 'http://localhost:8080' }); });
app.all('*', function (req, res) { proxy.web(req, res, { target: 'http://localhost:8080/' }); });
// Any requests to localhost:3000/build is proxied // to webpack-dev-server app.all('*', function (req, res) { proxy.web(req, res, { target: 'http://localhost:8080' }) })
app.use(function(req, res) { proxy.web(req, res) })