Submatter/apps/web/middleware.ts
Randall Stillwell 2f6adf4382 feat(web): Submatter marketing redesign with Signal Editorial system
Introduce public /landing and /pricing pages for the SBMTR brand with
bento features, convoy product demo, motion reveals, and scoped marketing
tokens. Unauthenticated visitors route to the landing page.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-10 22:50:05 -05:00

35 lines
953 B
TypeScript

import { auth } from "@/lib/auth";
import { NextResponse } from "next/server";
export default auth((req) => {
const { pathname } = req.nextUrl;
const isPublic =
pathname === "/" ||
pathname.startsWith("/landing") ||
pathname.startsWith("/sign-in") ||
pathname.startsWith("/sign-up") ||
pathname.startsWith("/api/auth");
if (isPublic) {
return NextResponse.next();
}
if (!req.auth) {
const signInUrl = new URL("/sign-in", req.url);
signInUrl.searchParams.set("callbackUrl", pathname);
return NextResponse.redirect(signInUrl);
}
return NextResponse.next();
});
export const config = {
matcher: [
/*
* Skip API (tRPC etc. handle their own auth), Next internals, and static files.
* Page routes under the (app) group are protected; (auth) and "/" stay public via logic above.
*/
"/((?!api|_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)",
],
};