This commit is contained in:
Ivan Rezchikov
2026-07-11 23:54:41 +03:00
parent a75dc470b5
commit ecd8940184
3 changed files with 6 additions and 3 deletions
+4 -2
View File
@@ -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));
}
}
+1
View File
@@ -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}
+1 -1
View File
@@ -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<ActionResult> {