From 1fc0d20e223639d1b112812d41378c7600be5b4b Mon Sep 17 00:00:00 2001 From: Nixyi Date: Thu, 12 Dec 2024 10:13:46 -0300 Subject: [PATCH] Added new error handling --- src/app/api/auth/login/route.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/api/auth/login/route.ts b/src/app/api/auth/login/route.ts index 9a02186..b736913 100644 --- a/src/app/api/auth/login/route.ts +++ b/src/app/api/auth/login/route.ts @@ -7,8 +7,19 @@ export async function POST(request: Request) { const {username, password} = await request.json() const supabase = await createClient() + const domain = process.env.DOMAIN; + console.log(domain) + if (!domain) { + return NextResponse.json({ + error: "Server is misconfigured, please check env variables and try again." + }, + { + status: 500 + }) + } + // Mocks the email with the domain we configured on the local env - const email = `${username.toLowerCase()}@${process.env.DOMAIN}` + const email = `${username.toLowerCase()}@${domain}` // Sends the request through supabase const {data: {user}, error: authError} = await supabase.auth.signInWithPassword({