mirror of
https://github.com/Since-3/since3-portal.git
synced 2026-10-12 20:51:17 +00:00
24 lines
No EOL
605 B
TypeScript
24 lines
No EOL
605 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { createClient } from "./lib/supabase/proxy";
|
|
|
|
|
|
const publicRoutes = ["/"]
|
|
|
|
export default async function proxy(request: NextRequest) {
|
|
const { supabase, response } = createClient(request)
|
|
|
|
const { data: { user } } = await supabase.auth.getUser()
|
|
|
|
const isPublicRoute = publicRoutes.includes(request.nextUrl.pathname)
|
|
|
|
if (!user && !isPublicRoute) {
|
|
return NextResponse.redirect(new URL("/", request.url))
|
|
}
|
|
|
|
return response
|
|
}
|
|
|
|
|
|
export const config = {
|
|
matcher: ["/((?!_next/static|_next/image|favicon.ico|pictures).*)"],
|
|
} |