forked from arikchakma/maily.to
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmiddleware.ts
30 lines (25 loc) · 928 Bytes
/
middleware.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
import { createMiddlewareClient } from '@supabase/auth-helpers-nextjs';
export async function middleware(req: NextRequest) {
const res = NextResponse.next();
// Create a Supabase client configured to use cookies
const supabase = createMiddlewareClient({ req, res });
// Refresh session if expired - required for Server Components
// https://supabase.com/docs/guides/auth/auth-helpers/nextjs#managing-session-with-middleware
await supabase.auth.getSession();
return res;
}
export const config = {
matcher: [
/*
* Match all paths except for:
* 1. /api routes
* 2. /_next (Next.js internals)
* 4. /_static (inside /public)
* 5. /_vercel (Vercel internals)
* 6. all root files inside /public (e.g. /favicon.ico)
*/
'/((?!api|_next|_static|_vercel|[\\w-]+\\.\\w+).*)',
],
};