aboutsummaryrefslogtreecommitdiff
path: root/apps/web/middleware.ts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/middleware.ts')
-rw-r--r--apps/web/middleware.ts42
1 files changed, 21 insertions, 21 deletions
diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts
index 068b8859..8658c0d8 100644
--- a/apps/web/middleware.ts
+++ b/apps/web/middleware.ts
@@ -1,29 +1,29 @@
-import { $fetch } from "@lib/api"
-import { getSessionCookie } from "better-auth/cookies"
-import { NextResponse } from "next/server"
+import { $fetch } from "@lib/api";
+import { getSessionCookie } from "better-auth/cookies";
+import { NextResponse } from "next/server";
export default async function middleware(request: Request) {
- console.debug("[MIDDLEWARE] === MIDDLEWARE START ===")
- const url = new URL(request.url)
- console.debug("[MIDDLEWARE] Path:", url.pathname)
- console.debug("[MIDDLEWARE] Method:", request.method)
+ console.debug("[MIDDLEWARE] === MIDDLEWARE START ===");
+ const url = new URL(request.url);
+ console.debug("[MIDDLEWARE] Path:", url.pathname);
+ console.debug("[MIDDLEWARE] Method:", request.method);
- const sessionCookie = getSessionCookie(request)
- console.debug("[MIDDLEWARE] Session cookie exists:", !!sessionCookie)
+ const sessionCookie = getSessionCookie(request);
+ console.debug("[MIDDLEWARE] Session cookie exists:", !!sessionCookie);
// Always allow access to login and waitlist pages
- const publicPaths = ["/login"]
+ const publicPaths = ["/login"];
if (publicPaths.includes(url.pathname)) {
- console.debug("[MIDDLEWARE] Public path, allowing access")
- return NextResponse.next()
+ console.debug("[MIDDLEWARE] Public path, allowing access");
+ return NextResponse.next();
}
// If no session cookie and not on a public path, redirect to login
if (!sessionCookie) {
console.debug(
"[MIDDLEWARE] No session cookie and not on public path, redirecting to /login",
- )
- return NextResponse.redirect(new URL("/login", request.url))
+ );
+ return NextResponse.redirect(new URL("/login", request.url));
}
if (url.pathname !== "/waitlist") {
@@ -31,20 +31,20 @@ export default async function middleware(request: Request) {
headers: {
Authorization: `Bearer ${sessionCookie}`,
},
- })
- console.debug("[MIDDLEWARE] Waitlist status:", response.data)
+ });
+ console.debug("[MIDDLEWARE] Waitlist status:", response.data);
if (response.data && !response.data.accessGranted) {
- return NextResponse.redirect(new URL("/waitlist", request.url))
+ return NextResponse.redirect(new URL("/waitlist", request.url));
}
}
- console.debug("[MIDDLEWARE] Passing through to next handler")
- console.debug("[MIDDLEWARE] === MIDDLEWARE END ===")
- return NextResponse.next()
+ console.debug("[MIDDLEWARE] Passing through to next handler");
+ console.debug("[MIDDLEWARE] === MIDDLEWARE END ===");
+ return NextResponse.next();
}
export const config = {
matcher: [
"/((?!_next/static|_next/image|images|icon.png|monitoring|opengraph-image.png|ingest|api|login|api/emails).*)",
],
-}
+};