From d050932cb6fc207f6eaae12fc8596b36541a6c69 Mon Sep 17 00:00:00 2001 From: sirin Date: Fri, 30 Aug 2024 20:57:38 +0700 Subject: [PATCH] Add middleware to create protected route --- src/middleware.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/middleware.ts diff --git a/src/middleware.ts b/src/middleware.ts new file mode 100644 index 0000000..9226aa2 --- /dev/null +++ b/src/middleware.ts @@ -0,0 +1,19 @@ +import { type NextRequest } from "next/server"; +import { updateSession } from "@/lib/supabase/middleware"; + +export async function middleware(request: NextRequest) { + return await updateSession(request); +} + +export const config = { + matcher: [ + /* + * Match all request paths except for the ones starting with: + * - _next/static (static files) + * - _next/image (image optimization files) + * - favicon.ico (favicon file) + * Feel free to modify this pattern to include more paths. + */ + "/((?!_next/static|_next/image|$|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)", + ], +};