Feat(LOY-230): DTMC Routes with Entra ID Auth & Error Page Handling * feat(LOY-230): Link Scandic Friends and Azure accounts * fix(LOY-230): remove employee id param setting * fix(LOY-230): return token in jwt callback for auth.dtmc.ts Approved-by: Michael Zetterberg Approved-by: Christian Andolf
21 lines
618 B
TypeScript
21 lines
618 B
TypeScript
import { type NextMiddleware, NextResponse } from "next/server"
|
|
|
|
import { handleDTMC } from "@/constants/routes/dtmc"
|
|
import { env } from "@/env/server"
|
|
import { notFound } from "@/server/errors/next"
|
|
|
|
import type { MiddlewareMatcher } from "@/types/middleware"
|
|
|
|
export const middleware: NextMiddleware = (request) => {
|
|
if (!env.ENABLE_DTMC) {
|
|
throw notFound(
|
|
`ENABLE_DTMC is disabled, returning notFound for DTMC Route: ${request.nextUrl.pathname}`
|
|
)
|
|
}
|
|
return NextResponse.next()
|
|
}
|
|
|
|
export const matcher: MiddlewareMatcher = (request) => {
|
|
return handleDTMC.includes(request.nextUrl.pathname)
|
|
}
|