refactor: move contentype to header
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user