Add logging to Discord verification process to identify errors
Enhance `api/discord/verify-code.ts` with additional console logs to aid in debugging Supabase client creation, code lookup, and general error handling, including more detailed error information in the response. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9203795e-937a-4306-b81d-b4d5c78c240e Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 409d1922-375f-4f4a-9fbf-f19ce19c2a34 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7c94b7a0-29c7-4f2e-94ef-44b2153872b7/9203795e-937a-4306-b81d-b4d5c78c240e/saoW2ee Replit-Helium-Checkpoint-Created: true
This commit is contained in:
parent
eb9424f16c
commit
a8efb3ccfa
1 changed files with 16 additions and 2 deletions
|
|
@ -30,8 +30,11 @@ export default async function handler(req: any, res: any) {
|
|||
}
|
||||
|
||||
try {
|
||||
console.log("[Discord Verify] Creating Supabase client with URL:", supabaseUrl?.substring(0, 30) + "...");
|
||||
const supabase = createClient(supabaseUrl, supabaseServiceRole);
|
||||
|
||||
console.log("[Discord Verify] Looking up code:", verification_code.trim());
|
||||
|
||||
// Find valid verification code
|
||||
const { data: verification, error: verifyError } = await supabase
|
||||
.from("discord_verifications")
|
||||
|
|
@ -40,6 +43,12 @@ export default async function handler(req: any, res: any) {
|
|||
.gt("expires_at", new Date().toISOString())
|
||||
.single();
|
||||
|
||||
console.log("[Discord Verify] Query result:", {
|
||||
found: !!verification,
|
||||
error: verifyError?.message,
|
||||
code: verifyError?.code
|
||||
});
|
||||
|
||||
if (verifyError) {
|
||||
console.error("[Discord Verify] Code lookup failed:", {
|
||||
code: verification_code.trim(),
|
||||
|
|
@ -112,10 +121,15 @@ export default async function handler(req: any, res: any) {
|
|||
discriminator: "0000",
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("[Discord Verify] Error:", error);
|
||||
} catch (error: any) {
|
||||
console.error("[Discord Verify] Error:", {
|
||||
message: error?.message,
|
||||
code: error?.code,
|
||||
stack: error?.stack?.substring(0, 500),
|
||||
});
|
||||
res.status(500).json({
|
||||
message: "An error occurred. Please try again.",
|
||||
debug: process.env.NODE_ENV === 'development' ? error?.message : undefined,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue