From ec5671ec9fa6cdd25398569aa4f8885fd87ccf64 Mon Sep 17 00:00:00 2001 From: Ivan Rezchikov Date: Wed, 16 Sep 2026 17:39:23 +0300 Subject: [PATCH] fix: proxy fixed --- kotosoft-id-frontend/proxy.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kotosoft-id-frontend/proxy.ts b/kotosoft-id-frontend/proxy.ts index 4b23e3d..829147b 100644 --- a/kotosoft-id-frontend/proxy.ts +++ b/kotosoft-id-frontend/proxy.ts @@ -9,7 +9,7 @@ export async function proxy(request: NextRequest) { const isPublicPath = PUBLIC_PATHS.includes(pathname); const session = request.nextUrl.searchParams.get("session"); - if (hasRefreshToken && session && pathname === "/login") { + if (session && pathname === "/login") { const accessToken = request.cookies.get("access_token")?.value; try { await fetch(`${process.env.KOTOSOFT_ID_API_URL}/oauth/session/attach`, { @@ -27,7 +27,11 @@ export async function proxy(request: NextRequest) { return NextResponse.redirect(new URL(`/consent?session=${session}`, request.url)); } - if (hasRefreshToken && (isPublicPath || pathname === "/")) { + if (session && pathname === "/consent") { + return NextResponse.next(); + } + + if (hasRefreshToken && !session && (isPublicPath || pathname === "/")) { return NextResponse.redirect(new URL("/me", request.url)); }