-
- Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
- Operating System: macOS 10.15.2
- Node Version: 12.8.1
- NPM Version: 6.10.2
- webpack Version: see
package.json
below - webpack-dev-server Version: see
package.json
below - Browser: N/A
- This is a bug
- This is a modification request
Code
// webpack.config.js module.exports = { devServer: { port: 4000, proxy: { '/api': 'http://localhost:3000' } } }
// index.js const express = require("express"); const app = express(); app.get("*", (req, res) => { res.send("foo"); }); // error handling middleware app.use((error, req, res, next) => { res.send("my custom error page"); }); app.listen(3000);
Expected Behavior
- Run
node index.js
- Run
webpack-dev-server
curl "localhost:4000/api/%"
The response should be "my custom error page"
, indicating that the Express error handling middleware for the API server was used.
Actual Behavior
The response is URIError: Failed to decode param …
, indicating that the Express error handling middleware for the API server was not used.
I would not expect webpack-dev-server
to change how errors are handled for proxied requests.
Technical notes
I played around with using http-proxy-middleware
on its own to see if the root issue was inside there, but using the following code, I could not reproduce this issue:
const httpProxyMiddleware = require("http-proxy-middleware"); const express = require("express"); { const app = express(); app.get("*", (req, res) => { res.send("foo"); }); app.use((error, req, res, next) => { res.send("my custom error page"); }); app.listen(3000); } { const app = express(); app.use(httpProxyMiddleware({ target: "http://localhost:3000" })); app.listen(4000); }
For Bugs; How can we reproduce the behavior?
See above
For Features; What is the motivation and/or use-case for the feature?
N/A
Metadata
Metadata
Assignees
Labels
No labels