Add new user paths, update user routing to new (WORKING!) user auth version of BE

This commit is contained in:
Hannah dagemark 2026-09-10 10:59:58 +02:00
commit d3064fd764
5 changed files with 54 additions and 1 deletions

View file

@ -1,7 +1,7 @@
const BACKEND_URL = process.env.BACKEND_URL; const BACKEND_URL = process.env.BACKEND_URL;
export async function POST(request: Request) { export async function POST(request: Request) {
const response = await fetch(`${BACKEND_URL}/users/token`, request); const response = await fetch(`${BACKEND_URL}/users/auth`, request);
const data = await response.json(); const data = await response.json();

View file

@ -0,0 +1,19 @@
const BACKEND_URL = process.env.BACKEND_URL;
export async function GET(
_request: Request,
{ params }: { params: Promise<{ id: string }> },
) {
const { id } = await params;
const response = await fetch(`${BACKEND_URL}/users/user/id/${id}`);
if (!response.ok) {
return new Response("Request failed in backend", {
status: response.status,
});
}
const data = await response.json();
return Response.json(data);
}

View file

@ -0,0 +1,15 @@
const BACKEND_URL = process.env.BACKEND_URL;
export async function GET() {
const response = await fetch(`${BACKEND_URL}/users/user`);
if (!response.ok) {
return new Response("Request failed in backend", {
status: response.status,
});
}
const data = await response.json();
return Response.json(data);
}

View file

@ -0,0 +1,19 @@
const BACKEND_URL = process.env.BACKEND_URL;
export async function GET(
_request: Request,
{ params }: { params: Promise<{ username: string }> },
) {
const { username } = await params;
const response = await fetch(`${BACKEND_URL}/users/user/name/${username}`);
if (!response.ok) {
return new Response("Request failed in backend", {
status: response.status,
});
}
const data = await response.json();
return Response.json(data);
}