Custom middleware request body gets overriden
See original GitHub issueI have custom middleware that appends request body and puts some value there. But when is form-data, that appended value dissapears from request body. I did a bit of investigation around and i found why.
In multer file lib/make-middleware.js
at line 27, there is this piece of code req.body = Object.create(null)
which destroys previous set values by my middleware. I simply commented this and solved problem for me. I didn’t go further to investigate why this piece of code exists and purpose of it.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:16 (5 by maintainers)
Top Results From Across the Web
Rewind request body stream - asp.net - Stack Overflow
Just found one solution. Replacing the original stream with a new stream containing the data. public override async Task Invoke(IOwinContext ...
Read more >Use Custom Middleware to Detect and Fix 404s in ASP.NET ...
To do that, I create a service called RequestTracker that records instances of 404 requests based on their path. RequestTracker is passed into...
Read more >Method Override Middleware | Echo - High performance ...
Method override middleware checks for the overridden method from the request and uses it instead of the original method. For security reasons, only...
Read more >Middleware - FastAPI
A "middleware" is a function that works with every request before it is processed by any specific path operation. And also with every...
Read more >Express body-parser middleware
A new body object containing the parsed data is populated on the request object after the middleware (i.e. req.body ). This will be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
in any case it wouldn’t harm to extend the existing
.body
with yourbody
instead of overwriting. if the fields with same name appear in the form-data request - they will be overwritten as before, isn’t it?Hi @jonchurch , I have created a PR, could you please review it.