Browse Source

fix: update error handling for forbidden and empty pages in page info API

Yuki Takei 3 months ago
parent
commit
cc84964f8d
1 changed files with 14 additions and 1 deletions
  1. 14 1
      apps/app/src/server/routes/apiv3/page/index.ts

+ 14 - 1
apps/app/src/server/routes/apiv3/page/index.ts

@@ -591,7 +591,20 @@ module.exports = (crowi: Crowi) => {
         );
         );
 
 
         if (isIPageNotFoundInfo(meta)) {
         if (isIPageNotFoundInfo(meta)) {
-          return res.apiv3Err(`Page '${pageId}' is not found or forbidden`);
+          // Return error only when the page is forbidden
+          // Empty pages (isEmpty: true) should return page info for UI operations
+          if (meta.isForbidden) {
+            return res.apiv3Err(
+              new ErrorV3(
+                'Page is forbidden',
+                'page-is-forbidden',
+                undefined,
+                meta,
+              ),
+              403,
+            );
+          }
+          // For not found but not forbidden pages (isEmpty: true), return the meta info
         }
         }
 
 
         return res.apiv3(meta);
         return res.apiv3(meta);