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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user