The guide was written for Next.js 15, where middleware.ts is the convention. Next.js 16 renamed the middleware file to proxy.ts and changed the export signature, so the old code is ignored and authentication session refresh fails.
1. Create a new Next.js 16 project.
2. Install @supabase/ssr and supabase-ui.
3. Follow the password-based auth guide at https://supabase.com/ui/docs/nextjs/password-based-auth.
4. Create a file named middleware.ts as shown in the guide.
5. Run the dev server and attempt to sign in or access a protected page.
6. Observe that middleware does not run (session refresh fails, protected routes not enforced).
Replace the legacy middleware.ts with proxy.ts and export a default async proxy function. Use createServerClient from @supabase/ssr with manual cookie handling for request/response cookies, which is the recommended pattern for Next.js 16 and avoids the deprecated middleware convention.
Edge Case Audit
This is a documentation-only fix. If you are still on Next.js 15, keep using middleware.ts. When migrating to Next.js 16, rename the file and update the export signature. Rollback: revert file name and export to middleware.ts if downgrading to Next.js 15. Edge runtime restrictions apply; avoid Node-specific imports.