Created
January 7, 2016 22:51
-
-
Save honzabrecka/675608e5b6f79c19db1d to your computer and use it in GitHub Desktop.
proxy
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
const fs = require('fs') | |
const express = require('express') | |
const proxy = require("http-proxy").createProxyServer({"changeOrigin": true}) | |
const index = './src/index.html' | |
const port = 3000 | |
const proxyTarget = '...' | |
const app = express() | |
app.use('/public', express.static('./target/public')) | |
app.use('/proxy', (req, res) => proxy.web(req, res, {target: proxyTarget})) | |
app.get('/', (req, res) => fs.readFile(index, 'utf8', (error, template) => { | |
if (error) throw new Error(error) | |
res.send(template) | |
})) | |
const server = app.listen(port, () => { | |
console.log('Server started at http://localhost:' + port) | |
}) |
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
{ | |
"dependencies": { | |
"express": "4.13.3", | |
"http-proxy": "1.12.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment