Created
February 10, 2015 18:22
-
-
Save joshblack/fd77c2fb359105d85a56 to your computer and use it in GitHub Desktop.
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 http = require('http'), | |
| express = require('express'), | |
| app = express(), | |
| cookieParser = require('cookie-parser'), | |
| httpProxy = require('http-proxy'); | |
| var proxy = httpProxy.createProxyServer({}); | |
| var proxyOptions = { | |
| 'host': 'http://127.0.0.1', | |
| 'port': '3000' | |
| }; | |
| var CLIENT_ID = process.env.CLIENT_ID || 'client_id'; | |
| var CLIENT_SECRET = process.env.CLIENT_SECRET || 'client_secret'; | |
| var COOKIE_SECRET = process.env.COOKIE_SECRET || 'cookie_secret'; | |
| app.use(cookieParser()); | |
| app.use('/*', function (req, res) { | |
| proxy.web(req, res, { | |
| target: proxyOptions.host + ':' + proxyOptions.port + req.baseUrl | |
| }); | |
| }); | |
| // Modify outgoing requests | |
| proxy.on('proxyReq', function(proxyReq, req, res, options) { | |
| // proxyReq.setHeader('X-Special-Proxy-Header', 'foobar') | |
| // proxyReq.setHeader('Authorization', ''); | |
| }); | |
| // Modify incoming requests | |
| proxy.on('proxyRes', function (proxyRes, req, res, options) { | |
| console.log('RAW Response from the target', JSON.stringify(proxyRes.headers, true, 2)); | |
| }); | |
| app.listen(9000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment