http-proxy-middleware
http-proxy-middleware copied to clipboard
Ability to support history fallback for single page application
Expected behavior
Redirect to $URI index.html with current url when reloaded or refreshed.
Actual behavior
404, as express setup expects a url in the backend.
Setup
- http-proxy-middleware: 0.17.4
- server: express
- other relevant modules - history-fallback-connect
proxy Setup
const FEProxy = proxy({ target: 'http://localhost:3000', proxyTimeout: 10000 });
const BEProxy = proxy({ target: 'http://localhost:9001', proxyTimeout: 10000 });
const app = express();
app.use('/edge', BEProxy);
app.use('/', FEProxy);
app.listen(8000, () => {
console.log('Proxy started listening at 8000');
});
I tried to use, https://github.com/bripkens/connect-history-api-fallback but proxying stops working. Could you please advice on how I can setup history fallback with front end proxy setup using express setup above.
Thank you @chimurai for such an awesome lib!
Cheers, Jeremy
@jeremyrajan Did you find a solution for this?
pathRewrite: function (path, req) {
if (path == "/" || path == "") {
return "/index.html";
}
return path.replace("^/", "/");
}