SupabaseS
Supabase4mo ago
boogsh

Supabase Middleware not working

Hello, my middleware on my app is not working, i think, i am just checking to see if the middleware will redirect me '/' to '/dashboard' thats it. BUT ITS NOT redirecting
CODE:
// middleware.ts
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";

export function middleware(request: NextRequest) {
// Only redirect if the user is at '/'
if (request.nextUrl.pathname === "/") {
const url = request.nextUrl.clone();
url.pathname = "/dashboard";
return NextResponse.redirect(url);
}

// Otherwise, just continue
return NextResponse.next();
}

// Apply to only '/' path
export const config = {
matcher: ["/"],
};
Was this page helpful?