feat: worst-scan fansub web — initial release
Posts engine (SQLite + auto-publisher via poller), public feed with clickable tags, reader, admin panel, submit/search/queue tools. BFF proxy to pipeline API. Clean dark design. Docker-ready.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { NextRequest, NextResponse } from "next/server"
|
||||
import { verifySession } from "@/lib/auth"
|
||||
|
||||
const publicPaths = [
|
||||
"/login",
|
||||
"/api/auth/login",
|
||||
"/api/auth/logout",
|
||||
"/api/proxy/health",
|
||||
"/api/posts",
|
||||
"/api/cover",
|
||||
"/api/cron",
|
||||
"/_next",
|
||||
"/favicon.ico",
|
||||
"/fonts",
|
||||
]
|
||||
|
||||
export async function middleware(req: NextRequest) {
|
||||
const { pathname } = req.nextUrl
|
||||
|
||||
const isPublic = publicPaths.some((p) => pathname.startsWith(p))
|
||||
if (isPublic) return NextResponse.next()
|
||||
|
||||
const isPublicPage = pathname === "/" || pathname.startsWith("/p/") || pathname.startsWith("/tag/")
|
||||
if (isPublicPage) return NextResponse.next()
|
||||
|
||||
const webPassword = process.env.WEB_PASSWORD
|
||||
if (!webPassword) return NextResponse.next()
|
||||
|
||||
const session = req.cookies.get("session")?.value
|
||||
if (!session) {
|
||||
return NextResponse.redirect(new URL("/login", req.url))
|
||||
}
|
||||
|
||||
const payload = await verifySession(session)
|
||||
if (!payload || !payload.authenticated) {
|
||||
return NextResponse.redirect(new URL("/login", req.url))
|
||||
}
|
||||
|
||||
return NextResponse.next()
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"],
|
||||
}
|
||||
Reference in New Issue
Block a user