When I hit /api/graphql then everything works fine. But when I try to hit non-existing API endpoint, e.g. /api/something then, the http-proxy-middleware throws the following exception:
index.js?46cb:598 Uncaught TypeError: next is not a function
at HttpProxyMiddleware.middleware (/Users/tomasz/Projects/http-middleware-issue/node_modules/http-proxy-middleware/dist/http-proxy-middleware.js:29:17)
at Object.apiResolver (/Users/tomasz/Projects/http-middleware-issue/node_modules/next/dist/server/api-utils/node.js:372:15)
at DevServer.runApi (/Users/tomasz/Projects/http-middleware-issue/node_modules/next/dist/server/next-server.js:488:27)
Checks
http-proxy-middleware
.Describe the bug (be clear and concise)
In my project, I have configured
When I hit
/api/graphql
then everything works fine. But when I try to hit non-existing API endpoint, e.g./api/something
then, the http-proxy-middleware throws the following exception:The error comes from this line: https://github.com/chimurai/http-proxy-middleware/blob/v2.0.6/src/http-proxy-middleware.ts#L59
This seems to be fixed some time ago in v3 but has not been released yet: https://github.com/chimurai/http-proxy-middleware/commit/4a081fe1b8622c3853c2396a21f9274e00a01df6#diff-07e6ad10bda0df091b737caed42767657cd0bd74a01246a1a0b7ab59c0f6e977R55
Is there a chance to get a 2.x release with a bug fix?
Step-by-step reproduction instructions
Or follow README from https://github.com/TomaszG/http-proxy-middleware-redirect-issue
Expected behavior (be clear and concise)
No error is thrown
How is http-proxy-middleware used in your project?
What http-proxy-middleware configuration are you using?
NextJS with http-proxy-middleware for backend redirects:
next.config.js is as follows:
What OS/version and node/version are you seeing the problem?
Additional context (optional)
No response