diff options
| author | Dhravya Shah <[email protected]> | 2025-09-18 20:34:18 -0700 |
|---|---|---|
| committer | Dhravya Shah <[email protected]> | 2025-09-18 21:03:49 -0700 |
| commit | 1fcb56908920da386900abb4ce2383374a625c72 (patch) | |
| tree | 0f9d7f695d4c9b1b85be3950fc869e0061dff3ed /apps/web/middleware.ts | |
| parent | refetching logic change (diff) | |
| download | supermemory-09-18-formatting.tar.xz supermemory-09-18-formatting.zip | |
formatting09-18-formatting
Diffstat (limited to 'apps/web/middleware.ts')
| -rw-r--r-- | apps/web/middleware.ts | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts index f9d24cd8..efd8f64b 100644 --- a/apps/web/middleware.ts +++ b/apps/web/middleware.ts @@ -1,30 +1,30 @@ -import { getSessionCookie } from "better-auth/cookies" -import { NextResponse } from "next/server" +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", - ) - const url = new URL("/login", request.url) - url.searchParams.set("redirect", request.url) - return NextResponse.redirect(url) + ); + const url = new URL("/login", request.url); + url.searchParams.set("redirect", request.url); + return NextResponse.redirect(url); } // TEMPORARILY DISABLED: Waitlist check @@ -40,19 +40,19 @@ export default async function middleware(request: Request) { // } // } - console.debug("[MIDDLEWARE] Passing through to next handler") - console.debug("[MIDDLEWARE] === MIDDLEWARE END ===") - const response = NextResponse.next() + console.debug("[MIDDLEWARE] Passing through to next handler"); + console.debug("[MIDDLEWARE] === MIDDLEWARE END ==="); + const response = NextResponse.next(); response.cookies.set({ name: "last-site-visited", value: "https://app.supermemory.ai", domain: "supermemory.ai", - }) - return response + }); + return response; } export const config = { matcher: [ "/((?!_next/static|_next/image|images|icon.png|monitoring|opengraph-image.png|ingest|api|login|api/emails).*)", ], -} +}; |