Initial commit

This commit is contained in:
2026-03-27 19:35:14 +01:00
commit 38581b88a4
68 changed files with 12137 additions and 0 deletions

36
proxy.ts Normal file
View File

@@ -0,0 +1,36 @@
import { NextRequest, NextResponse } from "next/server";
import { getToken } from "next-auth/jwt";
const AUTH_ROUTES = ["/login", "/register"];
export async function proxy(request: NextRequest) {
const pathname = request.nextUrl.pathname;
const atMatch = pathname.match(/^\/@([a-zA-Z0-9_]{3,32})$/);
if (atMatch) {
const url = request.nextUrl.clone();
url.pathname = `/u/${atMatch[1].toLowerCase()}`;
return NextResponse.rewrite(url);
}
const token = await getToken({ req: request });
if (pathname.startsWith("/dashboard") && !token) {
const url = request.nextUrl.clone();
url.pathname = "/login";
url.searchParams.set("next", pathname);
return NextResponse.redirect(url);
}
if (AUTH_ROUTES.includes(pathname) && token) {
const url = request.nextUrl.clone();
url.pathname = "/dashboard";
return NextResponse.redirect(url);
}
return NextResponse.next();
}
export const config = {
matcher: ["/((?!api|_next/static|_next/image|favicon.ico|robots.txt|sitemap.xml).*)"]
};