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 &&
|
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} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -30,7 +30,7 @@ export const signInWithEmailAndPassword = async ({
|
||||||
|
|
||||||
return redirect(
|
return redirect(
|
||||||
createBusterRoute({
|
createBusterRoute({
|
||||||
route: BusterRoutes.APP_METRIC
|
route: BusterRoutes.APP_HOME
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue