Skip to content

Instantly share code, notes, and snippets.

@ankeetmaini
Created July 19, 2021 05:49
Show Gist options
  • Save ankeetmaini/ea0cb77e94ea77708d1786a064fb1d6b to your computer and use it in GitHub Desktop.
Save ankeetmaini/ea0cb77e94ea77708d1786a064fb1d6b to your computer and use it in GitHub Desktop.
const httpProxy = require('http-proxy');
const proxy = httpProxy.createProxyServer({
target: 'http://proxy:8080'
});
// catching the gRPC requests here
// and removing the made-up /api
// before sending it to proxy
app.all('/api/*', (req, res) => {
req.url = req.url.replace('/api', '');
proxy.web(req, res, (e) => console.error(e));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment