Skip to content
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

update request body or query in alias-level middleware not work #223

Open
XHMM opened this issue Dec 25, 2020 · 3 comments
Open

update request body or query in alias-level middleware not work #223

XHMM opened this issue Dec 25, 2020 · 3 comments

Comments

@XHMM
Copy link

XHMM commented Dec 25, 2020

When route-level middleware changed request body or query, action can get changed data, but if alias-level middleware changed it, it not work.

Here is a reproduce demo: after run npm run dev, then run curl -X POST localhost:8080/test, you can find the (maybe) bug.

@icebob
Copy link
Member

icebob commented Dec 27, 2020

The reason is that the "query", "body" and "params" are processed after route middleware. So before action middlewares called, they are merged into req.$params, so you can modify through it, it will be the ctx.params.

@XHMM
Copy link
Author

XHMM commented Dec 29, 2020

Thanks for reply, with the help of view source code, I understood the internal.

I think the document description is not clear, which can make people mistakenly think that the use of the two middleware is the same, maybe should point out the difference?

@moleculerjs moleculerjs deleted a comment from XHMM Dec 31, 2020
@icebob
Copy link
Member

icebob commented Dec 31, 2020

Yeah, maybe the documentation needs some improvements to this topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants