26 lines
688 B
TypeScript
26 lines
688 B
TypeScript
import { NextResponse } from "next/server"
|
|
|
|
import { hotelReservation } from "@/constants/routes/hotelReservation"
|
|
|
|
import { findLang } from "@/utils/languages"
|
|
|
|
import { getDefaultRequestHeaders } from "./utils"
|
|
|
|
import type { NextMiddleware } from "next/server"
|
|
|
|
import type { MiddlewareMatcher } from "@/types/middleware"
|
|
|
|
export const middleware: NextMiddleware = (request) => {
|
|
const headers = getDefaultRequestHeaders(request)
|
|
return NextResponse.next({
|
|
request: {
|
|
headers,
|
|
},
|
|
})
|
|
}
|
|
|
|
export const matcher: MiddlewareMatcher = (request) => {
|
|
const lang = findLang(request.nextUrl.pathname)!
|
|
return request.nextUrl.pathname.startsWith(hotelReservation[lang])
|
|
}
|