fix(SW-2119): Fixed issue where we were redirecting to the parent instead of not found

Approved-by: Matilda Landström
This commit is contained in:
Erik Tiekstra
2025-04-16 04:52:26 +00:00
parent 65a3e3fc58
commit 42593dfe5e

View File

@@ -40,22 +40,21 @@ export const middleware: NextMiddleware = async (request) => {
await getUidAndContentTypeByPath(incomingPathNameParts.join("/"))
if (parentUid) {
contentType = parentContentType
uid = parentUid
switch (parentContentType) {
// If the parent is the startpage, we should not be able to resolve a subpage.
case PageContentTypeEnum.startPage:
throw notFound(
`Unable to resolve CMS entry for page "${pathWithoutTrailingSlash}"`
)
case PageContentTypeEnum.hotelPage:
// E.g. Dedicated pages for restaurant, parking etc.
searchParams.set("subpage", subpage)
contentType = parentContentType
uid = parentUid
break
case PageContentTypeEnum.destinationCityPage:
case PageContentTypeEnum.destinationCountryPage:
// E.g. Active filters inside destination pages to filter hotels.
searchParams.set("filterFromUrl", subpage)
contentType = parentContentType
uid = parentUid
break
default:
break
}
}