From cdbd6e820b87943e596f225df724ad5a1cd7818f Mon Sep 17 00:00:00 2001 From: rijkvanzanten Date: Wed, 7 Apr 2021 12:54:23 -0400 Subject: [PATCH] Tweak static handler path for extensions --- api/src/controllers/extensions.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/api/src/controllers/extensions.ts b/api/src/controllers/extensions.ts index 7390847b03..49324d05fb 100644 --- a/api/src/controllers/extensions.ts +++ b/api/src/controllers/extensions.ts @@ -8,17 +8,20 @@ import { respond } from '../middleware/respond'; const router = Router(); const extensionsPath = env.EXTENSIONS_PATH as string; -router.use(express.static(extensionsPath)); + +const appExtensions = ['interfaces', 'layouts', 'displays', 'modules']; router.get( - '/:type', + '/:type/*', asyncHandler(async (req, res, next) => { - const typeAllowList = ['interfaces', 'layouts', 'displays', 'modules']; - - if (typeAllowList.includes(req.params.type) === false) { + if (appExtensions.includes(req.params.type) === false) { throw new RouteNotFoundException(req.path); } + return next(); + }), + express.static(extensionsPath), + asyncHandler(async (req, res, next) => { const extensions = await listExtensions(req.params.type); res.locals.payload = {