Merged in fix/get-from-contentstack (pull request #1378)

* fix: include lang when fetching from contentstack


Approved-by: Matilda Landström
This commit is contained in:
Joakim Jäderberg
2025-02-19 14:28:10 +00:00
parent b6bf1b3ded
commit 0d6bbf7b78

View File

@@ -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.