fix
This commit is contained in:
@@ -21,6 +21,8 @@ function checkRateLimit(ip: string): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function GET(request: NextRequest) {
|
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";
|
const ip = request.headers.get("x-forwarded-for") ?? request.headers.get("x-real-ip") ?? "unknown";
|
||||||
if (!checkRateLimit(ip)) {
|
if (!checkRateLimit(ip)) {
|
||||||
return NextResponse.json({ message: "Too many requests" }, { status: 429 });
|
return NextResponse.json({ message: "Too many requests" }, { status: 429 });
|
||||||
@@ -75,10 +77,10 @@ export async function GET(request: NextRequest) {
|
|||||||
await deleteOAuthCookies();
|
await deleteOAuthCookies();
|
||||||
console.log("12. done");
|
console.log("12. done");
|
||||||
|
|
||||||
return NextResponse.redirect("/account");
|
return NextResponse.redirect(new URL("/account", baseUrl));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("OAuth callback error:", e);
|
console.error("OAuth callback error:", e);
|
||||||
console.error("Stack trace:", e instanceof Error ? e.stack : "No stack");
|
console.error("Stack trace:", e instanceof Error ? e.stack : "No stack");
|
||||||
return NextResponse.redirect("/callback/error");
|
return NextResponse.redirect(new URL("/callback/error", baseUrl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ services:
|
|||||||
PUBLIC_URL: ${PUBLIC_URL}
|
PUBLIC_URL: ${PUBLIC_URL}
|
||||||
DATABASE_URL: ${DATABASE_URL}
|
DATABASE_URL: ${DATABASE_URL}
|
||||||
|
|
||||||
|
KOTOSOFT_ID_API_PUBLIC_URL: ${KOTOSOFT_ID_API_PUBLIC_URL}
|
||||||
KOTOSOFT_ID_API_URL: ${KOTOSOFT_ID_API_URL}
|
KOTOSOFT_ID_API_URL: ${KOTOSOFT_ID_API_URL}
|
||||||
KOTOSOFT_CLIENT_ID: ${KOTOSOFT_CLIENT_ID}
|
KOTOSOFT_CLIENT_ID: ${KOTOSOFT_CLIENT_ID}
|
||||||
KOTOSOFT_CLIENT_SECRET: ${KOTOSOFT_CLIENT_SECRET}
|
KOTOSOFT_CLIENT_SECRET: ${KOTOSOFT_CLIENT_SECRET}
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ export async function login() {
|
|||||||
state,
|
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> {
|
export async function logout(): Promise<ActionResult> {
|
||||||
|
|||||||
Reference in New Issue
Block a user