feat(SW-66, SW-348): search functionality and ui

This commit is contained in:
Simon Emanuelsson
2024-08-28 10:47:57 +02:00
parent b9dbcf7d90
commit af850c90e7
437 changed files with 7663 additions and 9881 deletions

View File

@@ -2,7 +2,9 @@ import { NextResponse } from "next/server"
import { hotelReservation } from "@/constants/routes/hotelReservation"
import { resolve as resolveEntry } from "@/utils/entry"
import { findLang } from "@/utils/languages"
import { removeTrailingSlash } from "@/utils/url"
import { getDefaultRequestHeaders } from "./utils"
@@ -10,8 +12,21 @@ import type { NextMiddleware } from "next/server"
import type { MiddlewareMatcher } from "@/types/middleware"
export const middleware: NextMiddleware = (request) => {
export const middleware: NextMiddleware = async (request) => {
const { nextUrl } = request
const lang = findLang(nextUrl.pathname)!
const pathWithoutTrailingSlash = removeTrailingSlash(nextUrl.pathname)
const pathNameWithoutLang = pathWithoutTrailingSlash.replace(`/${lang}`, "")
const { contentType, uid } = await resolveEntry(pathNameWithoutLang, lang)
const headers = getDefaultRequestHeaders(request)
if (uid) {
headers.set("x-uid", uid)
}
if (contentType) {
headers.set("x-contenttype", contentType)
}
return NextResponse.next({
request: {
headers,