Update user routing, added user authorization with JWT cookie management

This commit is contained in:
Hannah dagemark 2026-09-14 23:09:11 +02:00
commit f055e77eea
7 changed files with 97 additions and 10 deletions

View file

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

View file

@ -15,7 +15,12 @@ export async function GET() {
}
export async function POST(request: Request) {
const response = await fetch(`${BACKEND_URL}/users`, request);
const response = await fetch(`${BACKEND_URL}/users`, {
method: "POST",
headers: request.headers,
body: request.body,
duplex: "half",
});
const data = await response.json();

View file

@ -1,7 +1,13 @@
const BACKEND_URL = process.env.BACKEND_URL;
export async function GET() {
const response = await fetch(`${BACKEND_URL}/users/user`);
export async function GET(request: Request) {
const authorization = request.headers.get("authorization");
const response = await fetch(`${BACKEND_URL}/users/user`, {
headers: {
Authorization: authorization ?? "",
},
});
if (!response.ok) {
return new Response("Request failed in backend", {