mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 05:15:17 +00:00
28 lines
745 B
TypeScript
28 lines
745 B
TypeScript
import { default as globalConfig } from "@/lib/config"
|
|
import { getSessionCookie } from "better-auth/cookies"
|
|
import { NextRequest, NextResponse } from "next/server"
|
|
|
|
export default async function middleware(request: NextRequest) {
|
|
if (globalConfig.selfHosted.isEnabled) {
|
|
return NextResponse.next()
|
|
}
|
|
|
|
const sessionCookie = getSessionCookie(request, { cookiePrefix: "taxhacker" })
|
|
if (!sessionCookie) {
|
|
return NextResponse.redirect(new URL(globalConfig.auth.loginUrl, request.url))
|
|
}
|
|
return NextResponse.next()
|
|
}
|
|
|
|
export const config = {
|
|
matcher: [
|
|
"/transactions/:path*",
|
|
"/settings/:path*",
|
|
"/export/:path*",
|
|
"/import/:path*",
|
|
"/unsorted/:path*",
|
|
"/files/:path*",
|
|
"/dashboard/:path*",
|
|
],
|
|
}
|