mirror of https://github.com/buster-so/buster.git
update middleware
This commit is contained in:
parent
770df9c1ff
commit
152845fe4b
|
@ -32,6 +32,12 @@ export default async function Layout({
|
|||
pathname !== newUserRoute &&
|
||||
!!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} />;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import { BusterRoutes, createBusterRoute } from '@/routes';
|
|||
export default function AppHomePage() {
|
||||
permanentRedirect(
|
||||
createBusterRoute({
|
||||
route: BusterRoutes.APP_METRIC
|
||||
route: BusterRoutes.APP_HOME
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
import { NextResponse, type NextRequest } from 'next/server';
|
||||
// import { updateSession } from './middleware/supabaseMiddleware';
|
||||
// import { isPublicPage } from './middleware/publicPageMiddleware';
|
||||
// import { BusterRoutes, createBusterRoute } from './routes';
|
||||
// import { cspPolicyMiddleware } from './middleware/cspPolicyMiddleware';
|
||||
// import { nextPathnameMiddleware } from './middleware/nextPathnameMiddleware';
|
||||
import { updateSession } from './middleware/supabaseMiddleware';
|
||||
import { isPublicPage } from './middleware/publicPageMiddleware';
|
||||
import { BusterRoutes, createBusterRoute } from './routes';
|
||||
import { cspPolicyMiddleware } from './middleware/cspPolicyMiddleware';
|
||||
import { nextPathnameMiddleware } from './middleware/nextPathnameMiddleware';
|
||||
|
||||
export async function middleware(request: NextRequest) {
|
||||
try {
|
||||
// const [supabaseResponse, user] = await updateSession(request);
|
||||
// const performUserCheck = !isPublicPage(request);
|
||||
// cspPolicyMiddleware(request);
|
||||
// nextPathnameMiddleware(request, supabaseResponse);
|
||||
// if (performUserCheck && !user && !request.nextUrl.pathname.includes('/test/')) {
|
||||
// return NextResponse.redirect(
|
||||
// new URL(createBusterRoute({ route: BusterRoutes.AUTH_LOGIN }), process.env.NEXT_PUBLIC_URL)
|
||||
// );
|
||||
// }
|
||||
// return supabaseResponse;
|
||||
const [supabaseResponse, user] = await updateSession(request);
|
||||
const performUserCheck = !isPublicPage(request);
|
||||
cspPolicyMiddleware(request);
|
||||
nextPathnameMiddleware(request, supabaseResponse);
|
||||
if (performUserCheck && !user && !request.nextUrl.pathname.includes('/test/')) {
|
||||
return NextResponse.redirect(
|
||||
new URL(createBusterRoute({ route: BusterRoutes.AUTH_LOGIN }), process.env.NEXT_PUBLIC_URL)
|
||||
);
|
||||
}
|
||||
return supabaseResponse;
|
||||
} catch (error) {
|
||||
console.error('Error in middleware:', error);
|
||||
return NextResponse.next();
|
||||
|
|
|
@ -30,7 +30,7 @@ export const signInWithEmailAndPassword = async ({
|
|||
|
||||
return redirect(
|
||||
createBusterRoute({
|
||||
route: BusterRoutes.APP_METRIC
|
||||
route: BusterRoutes.APP_HOME
|
||||
})
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue