Skip to content

Instantly share code, notes, and snippets.

@bentooth
Created January 30, 2018 17:13
Show Gist options
  • Save bentooth/20e44daab4406304cb2e178c53776c6d to your computer and use it in GitHub Desktop.
Save bentooth/20e44daab4406304cb2e178c53776c6d to your computer and use it in GitHub Desktop.
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