adminjs-nestjs: Using AdminBro alongside NestJS breaks payload validation
When the AdminModule is registered into root AppModule the validation errors are triggered in every other place, all the time as If the request contained no payload. I created a minimal reproduction repository https://github.com/pbn4/adminbro-nestjs-validation-bug/blob/master/src/app.module.ts and here is an example request:
curl -X POST http://localhost:3000/ -d '{"hello": "hello"}' -H "Content-Type: application/json"
Comment out AdminModule import in AppModule and see it working again.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 9
- Comments: 18 (6 by maintainers)
Commits related to this issue
- feat: added custom loader option, fixed #7 (thanks @niksoc) — committed to SoftwareBrothers/adminjs-nestjs by SimonB407 3 years ago
- fix: fixed issue with #7 when there is no cors middleware — committed to SoftwareBrothers/adminjs-nestjs by SimonB407 3 years ago
- chore(release): 1.1.0-beta.1 [skip ci] # [1.1.0-beta.1](https://github.com/SoftwareBrothers/admin-bro-nestjs/compare/v1.0.0...v1.1.0-beta.1) (2021-01-11) ### Bug Fixes * fixed issue with [#7](https... — committed to SoftwareBrothers/adminjs-nestjs by semantic-release-bot 3 years ago
- Merge pull request #10 from SoftwareBrothers/feat/custom-loader Custom loader & fix for #7 — committed to SoftwareBrothers/adminjs-nestjs by SimonB407 3 years ago
- chore(release): 1.1.0 [skip ci] # [1.1.0](https://github.com/SoftwareBrothers/admin-bro-nestjs/compare/v1.0.0...v1.1.0) (2021-03-12) ### Bug Fixes * fixed custom loader for factory providers, added... — committed to SoftwareBrothers/adminjs-nestjs by semantic-release-bot 3 years ago
@SimonB407 this issue occurs because admin-bro-nestjs pulls out jsonParser and urlencoded parser from their original position in the stack and pushes it back at the end of the stack. Unfortunately, this may be after all the route handling in nestjs. I’ve wrapped around the admin module to fix this temporarily.
@Hrach2003 I recommend using 1.1.0-beta.3. Beta 1 had some bugs.
Same happening to me here, all the request came with an empty body.
Any news on the proper fix for this? I wasn’t able to use it in a normal way with the latest published package (
1.1.0-beta.3).