From 4ac66b2b55eae3cfaf4581951e73f31eb6197174 Mon Sep 17 00:00:00 2001 From: qowevisa Date: Wed, 20 Nov 2024 18:21:53 +0200 Subject: [PATCH] Remove console.log and change type of function to RequestHandler for api/auth/login proxy request --- src/routes/api/auth/login/+server.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/routes/api/auth/login/+server.ts b/src/routes/api/auth/login/+server.ts index 4cb994f..a456d40 100644 --- a/src/routes/api/auth/login/+server.ts +++ b/src/routes/api/auth/login/+server.ts @@ -1,26 +1,16 @@ // src/routes/api/auth/login/+server.ts import { json } from '@sveltejs/kit'; import { login } from '$lib/api'; -import type { PageServerLoad } from '../../../test2/$types'; +import type { RequestHandler } from './$types'; -export const POST: PageServerLoad = async ({ request, cookies }) => { - console.log("in POST1") +export const POST: RequestHandler = async ({ request, cookies }) => { const authToken = request.headers.get('App-Token'); - console.log("authToken = ", authToken) - console.log("it should be = ", import.meta.env.VITE_AUTH_APP_TOKEN) if (authToken !== import.meta.env.VITE_AUTH_APP_TOKEN) { return json({ error: 'Forbidden' }, { status: 403 }); } - console.log("in POST2") const { username, password } = await request.json(); - - console.log("in POST3") try { - console.log("in POST4") const loginResponse = await login(username, password, cookies); - console.log("loginResponse = ", loginResponse) - - console.log("in POST5") return json({ id: loginResponse.id, name: loginResponse.name }); } catch (error) { return json({ error: error }, { status: 401 });