Last active
May 3, 2019 06:08
-
-
Save MouseZero/20c5fc1211d6379bc8787c620807691e to your computer and use it in GitHub Desktop.
http-proxy-server
This file contains 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 app, server, | |
proxy = require('express-http-proxy') | |
express = require('express'), | |
path = require('path'), | |
host = process.env.HOST || '127.0.0.1', | |
port = process.env.PORT || 3333, | |
root = path.resolve(__dirname, './src'); | |
app = express(); | |
app.use(function(req, res, next) { console.log(req.url); next(); }); | |
app.use(express.static(root + '/')); | |
app.use('/', proxy('www.google.com')); | |
server = app.listen(port, host, serverStarted); | |
function serverStarted () { | |
console.log('Server started', host, port); | |
console.log('Root directory', root); | |
console.log('Press Ctrl+C to exit...\n'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment