Created
January 30, 2018 17:13
-
-
Save bentooth/20e44daab4406304cb2e178c53776c6d to your computer and use it in GitHub Desktop.
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 express = require('express'); | |
const app = express(); | |
const path = require('path'); | |
const httpProxy = require('http-proxy'); | |
const renderer = require('./renderer'); | |
app.get(/^\/([^a]|a[^p]|ap[^i]|api[^/]).*$|^\/$/, renderer); | |
app.use(express.static(path.join(__dirname, '../build'))); | |
const proxy = httpProxy.createProxyServer(); | |
app.use('/api', (req, res) => { | |
proxy.web(req, res, {target: 'http://localhost:8081'}); | |
}); | |
app.listen(8080, () => { | |
console.log('App Server is listening on http://localhost:8080'); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment