Routing Middleware issues only on start on certain route
Unanswered
yoconn posted this in #help-forum
yoconnOP
I have no clue what in the world is happening
If i login, then try and navigate to /billing my middleware thinks a user isn't logged in and redirects them to signin.
/chat and /documents works perfectly fine, its just /billing and only in 'npm run start', however if i 'npm run dev' it works fine.
I've tried making billing client sided, server sided, asynchronous, empty, and a bunch of other stuff I can't remember.
I even went from the supabase-auth packages to the new supabase/ssr packages thinking that might be an issue, but again its only on /billing during start, dev is fine.
I also duplicated the exact same page into a new route /billing2, added it to the middleware, built it, ran it, and worked fine. It's just /billing...
If i login, then try and navigate to /billing my middleware thinks a user isn't logged in and redirects them to signin.
/chat and /documents works perfectly fine, its just /billing and only in 'npm run start', however if i 'npm run dev' it works fine.
I've tried making billing client sided, server sided, asynchronous, empty, and a bunch of other stuff I can't remember.
I even went from the supabase-auth packages to the new supabase/ssr packages thinking that might be an issue, but again its only on /billing during start, dev is fine.
I also duplicated the exact same page into a new route /billing2, added it to the middleware, built it, ran it, and worked fine. It's just /billing...
// middleware.ts
import { NextResponse, type NextRequest } from 'next/server'
import { createClient } from '@/utils/supabase/middleware'
import { getURL } from './utils/getURL';
export async function middleware(request: NextRequest) {
const { supabase, response } = createClient(request)
const { data: { session }, error } = await supabase.auth.getSession();
await supabase.auth.refreshSession(session!);
// console.log(session);
// No Session Found - Not LoggedIn?
if(session === null){
return NextResponse.redirect(`${getURL()}/signin`);
} else {
return response;
}
}
export const config = {
matcher: ['/documents', '/chat','/billing'],
// matcher: ['/account', '/billing', '/documents', '/chat'],
}//app/billing
export default function BillingPage(){
return(<>
<div>
Test
</div>
</>);
}