Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Node Reverse Proxy with Express
var fs = require('fs');
var express = require('express');
var request = require('request');
var apiUrl = ''; // remote host
var app = express();
// replace specific requests
app.get('/Scripts/js.js', function(req, res, next) {
console.log(req.url, req.query, 'script modified!');
app.use(function(req, res) {
console.log(req.url, req.query);
var url = apiUrl + req.url;
var proxy = request({
method: req.method,
url: url,
qs: req.query,
headers: req.headers
var server = app.listen(8575); // change port
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment