mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2025-12-08 12:36:44 +03:00
Fixed Tests
This commit is contained in:
@@ -4,7 +4,34 @@ import type { APIRoute } from "astro";
|
||||
export const ALL: APIRoute = async (ctx) => {
|
||||
// If you want to use rate limiting, make sure to set the 'x-forwarded-for' header
|
||||
// to the request headers from the context
|
||||
// ctx.request.headers.set("x-forwarded-for", ctx.clientAddress);
|
||||
if (ctx.clientAddress) {
|
||||
ctx.request.headers.set("x-forwarded-for", ctx.clientAddress);
|
||||
}
|
||||
|
||||
return auth.handler(ctx.request);
|
||||
try {
|
||||
return await auth.handler(ctx.request);
|
||||
} catch (error) {
|
||||
console.error("Auth handler error:", error);
|
||||
|
||||
// Check if this is an SSO callback error
|
||||
const url = new URL(ctx.request.url);
|
||||
if (url.pathname.includes('/sso/callback')) {
|
||||
// Redirect to error page for SSO errors
|
||||
return Response.redirect(
|
||||
`${ctx.url.origin}/auth-error?error=sso_callback_failed&error_description=${encodeURIComponent(
|
||||
error instanceof Error ? error.message : "SSO authentication failed"
|
||||
)}`,
|
||||
302
|
||||
);
|
||||
}
|
||||
|
||||
// Return a proper error response for other errors
|
||||
return new Response(JSON.stringify({
|
||||
error: "Internal server error",
|
||||
message: error instanceof Error ? error.message : "Unknown error"
|
||||
}), {
|
||||
status: 500,
|
||||
headers: { "Content-Type": "application/json" }
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user