Protecting routes with Nextjs Middleware
I tried adding this code from supabase website:
in the file "middleware.ts" inside pages, also tried after in "_middleware.ts", and doesn't work. In the first file it doesn't do anything, in the second one it gives me many errors. Changing /middleware-protected/:path* to "comments or /" for example doesn't do anything.
import { withMiddlewareAuth } from '@supabase/auth-helpers-nextjs'
export const middleware = withMiddlewareAuth({ redirectTo: '/login' })
export const config = {
matcher: ['/middleware-protected/:path*'],
}in the file "middleware.ts" inside pages, also tried after in "_middleware.ts", and doesn't work. In the first file it doesn't do anything, in the second one it gives me many errors. Changing /middleware-protected/:path* to "comments or /" for example doesn't do anything.