Last active
July 7, 2018 03:07
-
-
Save sandipchitale/b7236c812886a511486414a5ccbbb46f to your computer and use it in GitHub Desktop.
A simple proxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express(); | |
var httpProxy = require('http-proxy'); | |
var apiProxy = httpProxy.createProxyServer(); | |
var ias = 'http://localhost:8765'; | |
apiProxy.on('proxyReq', function (proxyReq, req, res) { | |
// console.log('RAW Request headers sent to target:\n', JSON.stringify(proxyReq.getHeaders(), true, 2)); | |
}) | |
app.all("/*", function(req, res) { | |
apiProxy.web(req, res, {target: ias}); | |
}); | |
app.listen(3000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "proxy", | |
"version": "1.0.0", | |
"description": "A simple proxy using express.", | |
"main": "index.js", | |
"scripts": { | |
"start": "node app.js", | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "Sandip Chitale", | |
"license": "ISC", | |
"dependencies": { | |
"express": "^4.16.3", | |
"http-proxy": "^1.17.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment