update middleware

This commit is contained in:
Nate Kelley 2025-03-10 09:09:44 -06:00
parent 770df9c1ff
commit 152845fe4b
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
4 changed files with 23 additions and 17 deletions

View File

@ -32,6 +32,12 @@ export default async function Layout({
pathname !== newUserRoute && pathname !== newUserRoute &&
!!accessToken //added to avoid bug with anon user !!accessToken //added to avoid bug with anon user
) { ) {
console.log('redirecting to new user route', userInfo?.organizations?.[0]?.id);
console.log(userInfo?.user?.name);
console.log(cookiePathname);
console.log(pathname);
console.log(newUserRoute);
console.log(accessToken);
return <ClientRedirect to={newUserRoute} />; return <ClientRedirect to={newUserRoute} />;
} }

View File

@ -4,7 +4,7 @@ import { BusterRoutes, createBusterRoute } from '@/routes';
export default function AppHomePage() { export default function AppHomePage() {
permanentRedirect( permanentRedirect(
createBusterRoute({ createBusterRoute({
route: BusterRoutes.APP_METRIC route: BusterRoutes.APP_HOME
}) })
); );

View File

@ -1,22 +1,22 @@
import { NextResponse, type NextRequest } from 'next/server'; import { NextResponse, type NextRequest } from 'next/server';
// import { updateSession } from './middleware/supabaseMiddleware'; import { updateSession } from './middleware/supabaseMiddleware';
// import { isPublicPage } from './middleware/publicPageMiddleware'; import { isPublicPage } from './middleware/publicPageMiddleware';
// import { BusterRoutes, createBusterRoute } from './routes'; import { BusterRoutes, createBusterRoute } from './routes';
// import { cspPolicyMiddleware } from './middleware/cspPolicyMiddleware'; import { cspPolicyMiddleware } from './middleware/cspPolicyMiddleware';
// import { nextPathnameMiddleware } from './middleware/nextPathnameMiddleware'; import { nextPathnameMiddleware } from './middleware/nextPathnameMiddleware';
export async function middleware(request: NextRequest) { export async function middleware(request: NextRequest) {
try { try {
// const [supabaseResponse, user] = await updateSession(request); const [supabaseResponse, user] = await updateSession(request);
// const performUserCheck = !isPublicPage(request); const performUserCheck = !isPublicPage(request);
// cspPolicyMiddleware(request); cspPolicyMiddleware(request);
// nextPathnameMiddleware(request, supabaseResponse); nextPathnameMiddleware(request, supabaseResponse);
// if (performUserCheck && !user && !request.nextUrl.pathname.includes('/test/')) { if (performUserCheck && !user && !request.nextUrl.pathname.includes('/test/')) {
// return NextResponse.redirect( return NextResponse.redirect(
// new URL(createBusterRoute({ route: BusterRoutes.AUTH_LOGIN }), process.env.NEXT_PUBLIC_URL) new URL(createBusterRoute({ route: BusterRoutes.AUTH_LOGIN }), process.env.NEXT_PUBLIC_URL)
// ); );
// } }
// return supabaseResponse; return supabaseResponse;
} catch (error) { } catch (error) {
console.error('Error in middleware:', error); console.error('Error in middleware:', error);
return NextResponse.next(); return NextResponse.next();

View File

@ -30,7 +30,7 @@ export const signInWithEmailAndPassword = async ({
return redirect( return redirect(
createBusterRoute({ createBusterRoute({
route: BusterRoutes.APP_METRIC route: BusterRoutes.APP_HOME
}) })
); );
}; };