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 });