mirror of
https://github.com/directus/directus.git
synced 2026-01-22 22:58:00 -05:00
Tweak static handler path for extensions
This commit is contained in:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user