Latest AdminJS (6.1.0) does not work with Nest.js 11
After upgrading Nest.js to v11 /admin path return 404 error.
It works with Nest.js 10.
Hi, I also facing the same issue, I found out that it will need to await this.loader.register at onModuleInit in admin.module.ts, but I not familiar on how to contribute to the github code
We are experiencing the same and couldn't find a solution for this yet
I am also facing the same issue after upgrade to Nestjs v11
Not worth considering if you are on Nest 11.
Any updates?
UPD
Those who struggling
diff --git a/node_modules/@adminjs/nestjs/build/admin.module.js b/node_modules/@adminjs/nestjs/build/admin.module.js
index e99b4f9..86ad837 100644
--- a/node_modules/@adminjs/nestjs/build/admin.module.js
+++ b/node_modules/@adminjs/nestjs/build/admin.module.js
@@ -70,7 +70,7 @@ let AdminModule = AdminModule_1 = class AdminModule {
const admin = new AdminJS(adminJSOptions);
admin.watch();
const { httpAdapter } = this.httpAdapterHost;
- this.loader.register(admin, httpAdapter, {
+ await this.loader.register(admin, httpAdapter, {
...this.adminModuleOptions,
adminJsOptions: admin.options,
});
Adding await in admin.moule.js file before this.loader.register helps
I think more steps are required. I can access /admin but my server can't find the assets (I added await before this.loader.register)
GET http://localhost:4010/admin/frontend/assets/global.bundle.js net::ERR_ABORTED 500 (Internal Server Error)Understand this error
GET http://localhost:4010/admin/frontend/assets/design-system.bundle.js net::ERR_ABORTED 500 (Internal Server Error)Understand this error
GET http://localhost:4010/admin/frontend/assets/app.bundle.js net::ERR_ABORTED 500 (Internal Server Error)
I really wanted to check whether routes of AdminJS are registered correctly, but there is no way to list all routes including sub routes in Express@5.
Here's what I did to get this working for my own project because I need it quick. I made these changes a while ago, so I might be missing some details, but this is the general approach:
- added the
awaitkeyword as suggested in the previous comment. - removed use of
formidable.jsbecause it conflicted with the body parser in NestJS 11. - switched to the built-in NestJS parser by adding
app.set('query parser', 'extended');to main.ts. - updated the code to use
req.bodyinstead of(req as any).fieldsto access parsed data from the express loader.
I have a custom ExpressLoader in my app and used the same route reordering logic as in src/loaders/express.loader.ts. After upgrading to NestJS 11, all my custom AdminJS route handlers stopped working.
The issue was that code in ExpressLoader#reorderRoutes expects an undocumented _router field, but newer versions of Express only provide the router field. Once I replaced _router with router, everything started working again.
I finally make it work thanks to @grokhotun and @McMerph comments. Also I have to put global.bundle.js, design-system.bundle.js app.bundle.js components.bundle.js to CDN instead of local file system, so that I can load them in any environment.
Hi, i don't understand how you manage to fix the express issue ?
Hi, i don't understand how you manage to fix the express issue ?
Go to a node_modules/@adminjs/nestjs/build/admin.module.js file in your node_modules folder, find this line
// some code before
this.loader.register(admin, httpAdapter, {
...this.adminModuleOptions,
adminJsOptions: admin.options
});
// some code after
and add await right before it so it would be
// some code before
await this.loader.register(admin, httpAdapter, {
...this.adminModuleOptions,
adminJsOptions: admin.options
});
// some code after
I have a custom
ExpressLoaderin my app and used the same route reordering logic as in src/loaders/express.loader.ts. After upgrading to NestJS 11, all my custom AdminJS route handlers stopped working.The issue was that code in
ExpressLoader#reorderRoutesexpects an undocumented_routerfield, but newer versions of Express only provide therouterfield. Once I replaced_routerwithrouter, everything started working again.
Thank you, this is what fixed it for me!
For those that want to patch it, edit build/loaders/express.loader.js and change any reference of _router to router.
I'm submitting a PR as well.
Facing the same issue. any news regarding the PR?