Closed satanshiro closed 6 months ago
Same problem
The /
is the behaviour from http-proxy
. (should be fix upstream)
Regarding the typing issue. You can provide appropriate request and response type from your server:
import type { Request, Response, NextFunction } from 'express';
createProxyMiddleware<Request, Response>{
target: config.env.TARGET_URL,
changeOrigin: true,
pathRewrite: (path, req) => req.originalUrl,
logger: console
}
@chimurai thank you! so i guess this is desired behavior, might be a good idea to add to the docs. thank you and have a nice day
Maybe a bit hidden... It's already documented here: https://github.com/chimurai/http-proxy-middleware?tab=readme-ov-file#express-server-example https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/servers.md#nextjs
I'll see how I can improve the docs 👍
Checks
http-proxy-middleware
.Describe the bug (be clear and concise)
when upgrading http proxy middleware in nest i am unable to path rewrite using req.url it always has the value '/' in order for the path rewrite to work as before i need to access a variable called original url that is not strongly typed on the request object this is my code:
Step-by-step reproduction instructions
Expected behavior (be clear and concise)
one of 2 : req.url to contain the original url or: originalUrl variable to be avaialble in they request type (currently http.IncomingMessage)
How is http-proxy-middleware used in your project?
What http-proxy-middleware configuration are you using?
What OS/version and node/version are you seeing the problem?
Additional context (optional)
No response