From 00b94976b74e45d2cb23f04c508df32ed0b5ca19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20J=C3=A4derberg?= Date: Thu, 20 Feb 2025 10:05:26 +0000 Subject: [PATCH] Merged in fix/hotel-subpage-unable-to-fetch (pull request #1381) fix: was unable to fetch hotel subpage data, now uses the same function as when fetching a 'normal' hotel page * fix: was unable to fetch hotel subpage data, now uses the same function as when fetching a 'normal' hotel page Approved-by: Linus Flood --- middlewares/cmsContent.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/middlewares/cmsContent.ts b/middlewares/cmsContent.ts index 5f5409e0c..f525c5d98 100644 --- a/middlewares/cmsContent.ts +++ b/middlewares/cmsContent.ts @@ -2,7 +2,6 @@ import { type NextMiddleware, NextResponse } from "next/server" import { notFound } from "@/server/errors/next" -import { fetchAndCacheEntry } from "@/services/cms/fetchAndCacheEntry" import { getUidAndContentTypeByPath } from "@/services/cms/getUidAndContentTypeByPath" import { findLang } from "@/utils/languages" import { removeTrailingSlash } from "@/utils/url" @@ -37,17 +36,15 @@ export const middleware: NextMiddleware = async (request) => { if (incomingPathNameParts.length >= 2) { const subpage = incomingPathNameParts.pop() if (subpage) { - const parentPageResult = await fetchAndCacheEntry( - incomingPathNameParts.join("/"), - lang - ) + let { contentType: parentContentType, uid: parentUid } = + await getUidAndContentTypeByPath(incomingPathNameParts.join("/")) - if (parentPageResult.uid) { - switch (parentPageResult.contentType) { + if (parentUid) { + switch (parentContentType) { case PageContentTypeEnum.hotelPage: // E.g. Dedicated pages for restaurant, parking etc. - contentType = parentPageResult.contentType - uid = parentPageResult.uid + contentType = parentContentType + uid = parentUid searchParams.set("subpage", subpage) break }