refactor: move contentype to header

This commit is contained in:
Matilda Landström
2024-05-29 13:47:27 +02:00
parent 286227705a
commit c8247bb2e4
9 changed files with 172 additions and 174 deletions

View File

@@ -26,9 +26,9 @@ export const middleware: NextMiddleware = async (request) => {
`Unable to resolve CMS entry for locale "${lang}": ${pathNameWithoutLang}`
)
}
const headers = getDefaultRequestHeaders(request)
headers.set("x-uid", uid)
headers.set("x-contenttype", contentType)
const isCurrent = contentType ? contentType.indexOf("current") >= 0 : false

View File

@@ -33,8 +33,7 @@ export const middleware: NextMiddleware = async (request) => {
}
const pathNameWithoutLang = nextUrl.pathname.replace(`/${lang}`, "")
const { uid } = await resolveEntry(pathNameWithoutLang, lang)
const { uid, contentType } = await resolveEntry(pathNameWithoutLang, lang)
if (!uid) {
throw notFound(
`Unable to resolve CMS entry for locale "${lang}": ${pathNameWithoutLang}`
@@ -43,6 +42,7 @@ export const middleware: NextMiddleware = async (request) => {
const headers = getDefaultRequestHeaders(request)
headers.set("x-uid", uid)
headers.set("x-contenttype", contentType)
return NextResponse.next({
request: {
headers,