diff --git a/frontend-next/src/app/api/onboard/route.js b/frontend-next/src/app/api/onboard/route.js index 0820fc5..a4eab8f 100644 --- a/frontend-next/src/app/api/onboard/route.js +++ b/frontend-next/src/app/api/onboard/route.js @@ -7,7 +7,7 @@ import { getDatabase, ref, set as firebaseSet } from "firebase/database"; async function onboard(firstName, lastName, req) { var session = req.cookies.get("session"); //Call the authentication endpoint - var res = await fetch("http://localhost:3000/api/login", {headers: {Cookie: `session=${session?.value}`}}) + var res = await fetch(new URL("/api/login", req.url), {headers: {Cookie: `session=${session?.value}`}}) // Login if unauthorized if (res.status !== 200) { diff --git a/frontend-next/src/middleware.js b/frontend-next/src/middleware.js index 7029033..abef4f5 100644 --- a/frontend-next/src/middleware.js +++ b/frontend-next/src/middleware.js @@ -10,7 +10,7 @@ export async function middleware(req, res) { return NextResponse.redirect(new URL("/login", req.url)); } //Call the authentication endpoint - const responseAPI = await fetch("http://localhost:3000/api/login", { + const responseAPI = await fetch(new URL("/api/login", req.url), { headers: { Cookie: `session=${session?.value}`, },