mirror of
https://github.com/vas3k/TaxHacker.git
synced 2026-05-05 13:59:11 -05: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*",
|
|
],
|
|
}
|