Add user login, signup, and session.

This commit is contained in:
Hannah dagemark 2026-09-02 21:39:39 +02:00
commit f5466faa70
6 changed files with 101 additions and 36 deletions

View file

@ -1,32 +1,25 @@
const BACKEND_URL = process.env.BACKEND_URL;
export async function GET() {
const response = await fetch(`${BACKEND_URL}/users`);
const response = await fetch(`${BACKEND_URL}/users`);
if (!response.ok) {
return new Response("Request failed in backend", { status: response.status, });
}
if (!response.ok) {
return new Response("Request failed in backend", {
status: response.status,
});
}
const data = await response.json();
const data = await response.json();
return Response.json(data);
return Response.json(data);
}
export async function POST(request: Request) {
const response = await fetch(`${BACKEND_URL}/users`, request);
const body = await request.json();
const data = await response.json();
const response = await fetch(`${BACKEND_URL}/users`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
const data = await response.json();
return Response.json(data, {
status: response.status,
});
}
return Response.json(data, {
status: response.status,
});
}