New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fixed issues with req.url
and added more tests
#413
base: master
Are you sure you want to change the base?
Conversation
const handle = (mw: Middleware) => async (req: Req, res: Res, next?: NextFunction) => { | ||
const { path, handler, regex } = mw | ||
|
||
req.url = reqUrlCopy // reset req.url since it is changed in the handle fn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we reset req.url here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have multiple middlewares for 1 path, the req.url
is modified as per
tinyhttp/packages/app/src/app.ts
Line 376 in 7bf2953
req.url = lead(req.originalUrl.substring(prefix.length)) |
and hence, every single middleware after the first receives the altered req.url
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
req.url is supposed to be modified. It's different for subapps. that's why req.originalUrl
exists
req.url
and added more tests
No description provided.