fixed authcontext for sign up, added 404 and middleware for prod readiness

This commit is contained in:
2025-12-12 11:10:49 -05:00
parent 777618f684
commit 1757aba3e7
6 changed files with 504 additions and 6 deletions
+38
View File
@@ -0,0 +1,38 @@
// middleware.ts
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
const LAUNCH_ONLY_ROOT = process.env.NEXT_PUBLIC_LAUNCH_ONLY_ROOT === "true";
// Allow only root + essential static files
const ALLOW = new Set([
"/",
"/favicon.ico",
"/robots.txt",
"/sitemap.xml",
]);
export function middleware(req: NextRequest) {
if (!LAUNCH_ONLY_ROOT) return NextResponse.next();
const { pathname } = req.nextUrl;
// Always allow Next internals + static assets
if (
pathname.startsWith("/_next") ||
pathname.startsWith("/assets") ||
pathname.startsWith("/images")
) {
return NextResponse.next();
}
// Allow the root + a few public files
if (ALLOW.has(pathname)) return NextResponse.next();
// Everything else: hide it
return NextResponse.rewrite(new URL("/404", req.url)); // or redirect to "/"
}
export const config = {
matcher: ["/:path*"],
};