setting up files

This commit is contained in:
masongga
2026-05-23 15:09:49 -06:00
parent 4a478a653e
commit 2ad9e42f3f
25 changed files with 881 additions and 108 deletions

View File

@@ -1,7 +1,8 @@
import { createServerClient } from "@supabase/ssr";
import { NextResponse, type NextRequest } from "next/server";
import { hasEnvVars } from "../utils";
import { isPublicPath, routes } from "@/lib/routes";
import { getSupabaseEnv } from "@/lib/supabase/env";
import { hasEnvVars } from "../utils";
export async function updateSession(request: NextRequest) {
let supabaseResponse = NextResponse.next({
@@ -50,15 +51,11 @@ export async function updateSession(request: NextRequest) {
const { data } = await supabase.auth.getClaims();
const user = data?.claims;
if (
request.nextUrl.pathname !== "/" &&
!user &&
!request.nextUrl.pathname.startsWith("/login") &&
!request.nextUrl.pathname.startsWith("/auth")
) {
// no user, potentially respond by redirecting the user to the login page
const { pathname } = request.nextUrl;
if (!user && !isPublicPath(pathname)) {
const url = request.nextUrl.clone();
url.pathname = "/auth/login";
url.pathname = routes.login;
return NextResponse.redirect(url);
}