added user rig submission, logout | initial

This commit is contained in:
makearmy 2025-09-26 14:18:24 -04:00
parent 9261fbc165
commit b341a3675e
8 changed files with 635 additions and 420 deletions

24
middleware.ts Normal file
View file

@ -0,0 +1,24 @@
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
const PROTECTED_PATHS = ["/my", "/api/my"];
export function middleware(req: NextRequest) {
const { pathname } = req.nextUrl;
const needsAuth = PROTECTED_PATHS.some(
(p) => pathname === p || pathname.startsWith(p + "/")
);
if (!needsAuth) return NextResponse.next();
const hasToken = Boolean(req.cookies.get("ma_at")?.value);
if (!hasToken) {
const url = new URL("/sign-in", req.url);
url.searchParams.set("next", pathname);
return NextResponse.redirect(url);
}
return NextResponse.next();
}
export const config = {
matcher: ["/((?!_next|static|favicon.ico).*)"],
};