From f4b35dcc30ff3868794b2589c23b01541dec8b98 Mon Sep 17 00:00:00 2001 From: Hermes Date: Wed, 10 Jun 2026 16:28:41 -0700 Subject: [PATCH] fix: correct apps route mount paths - mount all sub-routers at /apps prefix to match frontend API calls --- dashcaddy-api/routes/apps/index.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/dashcaddy-api/routes/apps/index.js b/dashcaddy-api/routes/apps/index.js index 52483df..45a154f 100644 --- a/dashcaddy-api/routes/apps/index.js +++ b/dashcaddy-api/routes/apps/index.js @@ -25,7 +25,6 @@ module.exports = function(ctx) { asyncHandler: ctx.asyncHandler, errorResponse: ctx.errorResponse, log: ctx.log, - // Additional context properties needed by routes APP_TEMPLATES: ctx.APP_TEMPLATES, TEMPLATE_CATEGORIES: ctx.TEMPLATE_CATEGORIES, DIFFICULTY_LEVELS: ctx.DIFFICULTY_LEVELS, @@ -40,25 +39,26 @@ module.exports = function(ctx) { ctx: ctx }; - // Initialize helpers with dependencies (ctx is the Koa context) const helpers = initHelpers({ ...deps, ctx }); - - // Mount sub-routes — pass full ctx so sub-routes can reference ctx.* properties const subCtx = Object.assign({}, ctx, { helpers }); - try { router.use('/', initDeploy(subCtx)); } + // Mount sub-routers at their prefix paths. + // Sub-modules define routes at '/' (root of their sub-router). + // Final paths: /api/v1/apps/deploy, /api/v1/apps/remove, /api/v1/apps/templates, etc. + + try { router.use('/apps', initDeploy(subCtx)); } catch(e) { (ctx.log || console).error('[apps] deploy routes init failed:', e.message, e.stack); } - try { router.use('/', initRemoval(subCtx)); } + try { router.use('/apps', initRemoval(subCtx)); } catch(e) { (ctx.log || console).error('[apps] removal routes init failed:', e.message, e.stack); } - try { router.use('/', initTemplates(subCtx)); } + try { router.use('/apps', initTemplates(subCtx)); } catch(e) { (ctx.log || console).error('[apps] templates routes init failed:', e.message, e.stack); } - try { router.use('/', initRestore(Object.assign({}, subCtx, { backupManager: ctx.backupManager }))); } + try { router.use('/apps', initRestore(Object.assign({}, subCtx, { backupManager: ctx.backupManager }))); } catch(e) { (ctx.log || console).error('[apps] restore routes init failed:', e.message, e.stack); } - try { router.use('/', initCompose(subCtx)); } + try { router.use('/apps', initCompose(subCtx)); } catch(e) { (ctx.log || console).error('[apps] compose routes init failed:', e.message, e.stack); } return router;