Server Components cannot set cookies in the Next.js App Router. In this lesson, we implement middleware to refresh expired Supabase sessions.
Middleware runs immediately before the route is loaded. By using it to refresh our user's session, we ensure it is valid by the time it loads the Server Component and attempts to fetch data from Supabase.
Refresh expired sessions
supabase.auth.getSession();