mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-14 04:00:54 +08:00
Comments, doc comments, UI labels, log and error messages, LLM prompt strings, markdown docs, test data and assertions. Identifiers, enum keys, routes, placeholders and code structure are unchanged. Notes: - docs/漏洞流量证据.md renamed to docs/vulnerability-traffic-evidence.md - tests that exercised CJK specific handling (GBK zip names, Chinese full text search) now use ASCII equivalents; go build passes and the test suite matches the pre translation baseline (remaining failures need a PostgreSQL DSN and fail identically on the original) - frontend mention syntax now uses English kinds (finding, asset, ...) matching the backend, chat mentions tests pass
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
import type { NextRequest } from "next/server";
|
|
|
|
const AUTH_PAGES = ["/login", "/setup"];
|
|
|
|
export function proxy(request: NextRequest) {
|
|
// Mock demo: no real login; allow every page (the client-side auth guard also allows through).
|
|
if (process.env.NEXT_PUBLIC_MOCK === "1") return NextResponse.next();
|
|
|
|
const { pathname } = request.nextUrl;
|
|
const token = request.cookies.get("artex_token")?.value;
|
|
const isAuthPage = AUTH_PAGES.some((p) => pathname === p || pathname.startsWith(`${p}/`));
|
|
|
|
// Not logged in → redirect to the login page
|
|
if (!token && !isAuthPage) {
|
|
return NextResponse.redirect(new URL("/login", request.url));
|
|
}
|
|
|
|
// Logged in while visiting the login/setup pages → redirect to the main UI
|
|
if (token && isAuthPage) {
|
|
return NextResponse.redirect(new URL("/function/tasks", request.url));
|
|
}
|
|
|
|
return NextResponse.next();
|
|
}
|
|
|
|
export const config = {
|
|
// Skip Next.js internal routes, API routes, favicon, and static files under public/ (images, fonts, etc.)
|
|
matcher: ["/((?!_next/static|_next/image|favicon\\.ico|api/|.*\\.(?:png|jpg|jpeg|gif|webp|svg|ico|woff2?|ttf|otf)$).*)"],
|
|
};
|