diff --git a/middlewares/cmsContent.ts b/middlewares/cmsContent.ts index a5615f3b2..166098679 100644 --- a/middlewares/cmsContent.ts +++ b/middlewares/cmsContent.ts @@ -26,14 +26,15 @@ export const middleware: NextMiddleware = async (request) => { ? contentTypePathName.replace("/preview", "") : contentTypePathName - let { contentType, uid } = await getUidAndContentTypeByPath(incomingPathName) + let { contentType, uid } = await getUidAndContentTypeByPath( + pathWithoutTrailingSlash + ) const searchParams = new URLSearchParams(request.nextUrl.searchParams) if (!contentType || !uid) { // Routes to subpages we need to check if the parent of the incomingPathName exists. // Then we considered the incomingPathName to be a subpage. These subpages do not live in the CMS. - const incomingPathNameParts = incomingPathName.split("/") // If the incomingPathName has 2 or more parts, it could possibly be a subpage.