Files
yt2mp3/server/routes/login.post.ts
2026-01-14 17:31:53 +00:00

23 lines
661 B
TypeScript

export default defineEventHandler(async (event) => {
const conf = useRuntimeConfig()
const body = await readBody(event)
if ( !body.email || !body.password )
throw createError({ statusCode: 400, message: "Bad form. Use e-mail and password" })
const req = await fetch(conf.fastapi_url + "/login",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: body.email!,
pwd: body.password!,
})
}
)
if (!req.ok) throw createError({ statusCode: req.status })
})