From ecd89401847424fd4c6fdfd6046d8cce63dc3811 Mon Sep 17 00:00:00 2001 From: Ivan Rezchikov Date: Sat, 11 Jul 2026 23:54:41 +0300 Subject: [PATCH] fix --- app/api/callback/route.ts | 6 ++++-- docker-compose.yml | 1 + lib/user/actions.ts | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/api/callback/route.ts b/app/api/callback/route.ts index e577800..c99a51a 100644 --- a/app/api/callback/route.ts +++ b/app/api/callback/route.ts @@ -21,6 +21,8 @@ function checkRateLimit(ip: string): boolean { } export async function GET(request: NextRequest) { + const baseUrl = process.env.PUBLIC_URL || request.nextUrl.origin; + const ip = request.headers.get("x-forwarded-for") ?? request.headers.get("x-real-ip") ?? "unknown"; if (!checkRateLimit(ip)) { return NextResponse.json({ message: "Too many requests" }, { status: 429 }); @@ -75,10 +77,10 @@ export async function GET(request: NextRequest) { await deleteOAuthCookies(); console.log("12. done"); - return NextResponse.redirect("/account"); + return NextResponse.redirect(new URL("/account", baseUrl)); } catch (e) { console.error("OAuth callback error:", e); console.error("Stack trace:", e instanceof Error ? e.stack : "No stack"); - return NextResponse.redirect("/callback/error"); + return NextResponse.redirect(new URL("/callback/error", baseUrl)); } } \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index d696733..c75d2bd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,7 @@ services: PUBLIC_URL: ${PUBLIC_URL} DATABASE_URL: ${DATABASE_URL} + KOTOSOFT_ID_API_PUBLIC_URL: ${KOTOSOFT_ID_API_PUBLIC_URL} KOTOSOFT_ID_API_URL: ${KOTOSOFT_ID_API_URL} KOTOSOFT_CLIENT_ID: ${KOTOSOFT_CLIENT_ID} KOTOSOFT_CLIENT_SECRET: ${KOTOSOFT_CLIENT_SECRET} diff --git a/lib/user/actions.ts b/lib/user/actions.ts index 2f2ea9e..73dddc4 100644 --- a/lib/user/actions.ts +++ b/lib/user/actions.ts @@ -30,7 +30,7 @@ export async function login() { state, }); - redirect(`${process.env.KOTOSOFT_ID_API_URL}/oauth/authorize?${params}`); + redirect(`${process.env.KOTOSOFT_ID_API_PUBLIC_URL}/oauth/authorize?${params}`); } export async function logout(): Promise {