From b9b892ec9f9bae8c5c62671bab76e30b060219cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s?= <690217+tomups@users.noreply.github.com> Date: Fri, 12 Sep 2025 00:17:28 +0200 Subject: [PATCH 1/2] fix: await loader.register so login page will render --- src/admin.module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/admin.module.ts b/src/admin.module.ts index 7fc4ae6..ba66ad6 100644 --- a/src/admin.module.ts +++ b/src/admin.module.ts @@ -138,7 +138,7 @@ export class AdminModule implements OnModuleInit { admin.watch(); const { httpAdapter } = this.httpAdapterHost; - this.loader.register(admin, httpAdapter, { + await this.loader.register(admin, httpAdapter, { ...this.adminModuleOptions, adminJsOptions: admin.options, }); From 42abbb0759528d559544e397c7404a895ccee871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s?= <690217+tomups@users.noreply.github.com> Date: Fri, 12 Sep 2025 00:18:52 +0200 Subject: [PATCH 2/2] fix: use router instead of _router from express v5 --- src/loaders/express.loader.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/loaders/express.loader.ts b/src/loaders/express.loader.ts index 00f235b..6b8c142 100644 --- a/src/loaders/express.loader.ts +++ b/src/loaders/express.loader.ts @@ -58,43 +58,43 @@ export class ExpressLoader extends AbstractLoader { // Nestjs uses bodyParser under the hood which is in conflict with adminjs setup. // Due to adminjs-expressjs usage of formidable we have to move body parser in layer tree after adminjs init. // Notice! This is not documented feature of express, so this may change in the future. We have to keep an eye on it. - if (app && app._router && app._router.stack) { - const jsonParserIndex = app._router.stack.findIndex( + if (app && app.router && app.router.stack) { + const jsonParserIndex = app.router.stack.findIndex( (layer: { name: string }) => layer.name === 'jsonParser', ); if (jsonParserIndex >= 0) { - jsonParser = app._router.stack.splice(jsonParserIndex, 1); + jsonParser = app.router.stack.splice(jsonParserIndex, 1); } - const urlencodedParserIndex = app._router.stack.findIndex( + const urlencodedParserIndex = app.router.stack.findIndex( (layer: { name: string }) => layer.name === 'urlencodedParser', ); if (urlencodedParserIndex >= 0) { - urlencodedParser = app._router.stack.splice(urlencodedParserIndex, 1); + urlencodedParser = app.router.stack.splice(urlencodedParserIndex, 1); } - const adminIndex = app._router.stack.findIndex( + const adminIndex = app.router.stack.findIndex( (layer: { name: string }) => layer.name === 'admin', ); if (adminIndex >= 0) { - admin = app._router.stack.splice(adminIndex, 1); + admin = app.router.stack.splice(adminIndex, 1); } // if adminjs-nestjs didn't reorder the middleware // the body parser would have come after corsMiddleware - const corsIndex = app._router.stack.findIndex( + const corsIndex = app.router.stack.findIndex( (layer: { name: string }) => layer.name === 'corsMiddleware', ); // in other case if there is no corsIndex we go after expressInit, because right after that // there are nest endpoints. - const expressInitIndex = app._router.stack.findIndex( + const expressInitIndex = app.router.stack.findIndex( (layer: { name: string }) => layer.name === 'expressInit', ); const initIndex = (corsIndex >= 0 ? corsIndex : expressInitIndex) + 1; - app._router.stack.splice( + app.router.stack.splice( initIndex, 0, ...admin,