website refactor
This commit is contained in:
@@ -4,6 +4,7 @@ import { SessionGateway } from '@/lib/gateways/SessionGateway';
|
||||
import { handleAuthFlow } from '@/lib/auth/AuthFlowRouter';
|
||||
import { ConsoleLogger } from '@/lib/infrastructure/logging/ConsoleLogger';
|
||||
import { routeMatchers } from '@/lib/routing/RouteConfig';
|
||||
import { SearchParamBuilder } from '@/lib/routing/search-params/SearchParamBuilder';
|
||||
|
||||
const logger = new ConsoleLogger();
|
||||
|
||||
@@ -78,7 +79,7 @@ export async function middleware(request: NextRequest) {
|
||||
} catch (error) {
|
||||
logger.error('[MIDDLEWARE] Error in auth flow', error instanceof Error ? error : new Error(String(error)));
|
||||
// Fallback: redirect to login if there's an error
|
||||
return NextResponse.redirect(new URL(`/auth/login?returnTo=${encodeURIComponent(pathname)}`, request.url));
|
||||
return NextResponse.redirect(new URL(`/auth/login${SearchParamBuilder.auth(pathname)}`, request.url));
|
||||
}
|
||||
|
||||
logger.info('[MIDDLEWARE] Decision summary', {
|
||||
@@ -121,4 +122,4 @@ export const config = {
|
||||
*/
|
||||
'/((?!_next/static|_next/image|_next/data|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp|mp4|webm|mov|avi)$).*)',
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user