From 7b32656e6ade23e46fd424e739344e203062d8b4 Mon Sep 17 00:00:00 2001 From: Boegie19 Date: Thu, 12 Oct 2023 22:09:33 +0200 Subject: [PATCH] add warning if route is not found --- .../server/utils/middlewares/injectMiddlewares.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/strapi-plugin-rest-cache/server/utils/middlewares/injectMiddlewares.js b/packages/strapi-plugin-rest-cache/server/utils/middlewares/injectMiddlewares.js index ae730116e..5e07fcf75 100644 --- a/packages/strapi-plugin-rest-cache/server/utils/middlewares/injectMiddlewares.js +++ b/packages/strapi-plugin-rest-cache/server/utils/middlewares/injectMiddlewares.js @@ -57,7 +57,13 @@ function injectMiddlewares(strapi, strategy) { ); // If the route exists lets inject the middleware - if (indexID > -1) { + if (indexID === -1) { + debug( + '[WARNING] route "[%s] %s" not registered in strapi, ignoring...', + cacheRoute.method, + cacheRoute.path + ); + } else { switch (strapiRoutes[indexID].method) { case 'DELETE': case 'PUT':