diff --git a/src/app/apiClient/registerUser.ts b/src/app/apiClient/registerUser.ts index 85edad1..ef2b3b3 100644 --- a/src/app/apiClient/registerUser.ts +++ b/src/app/apiClient/registerUser.ts @@ -1,6 +1,7 @@ export const registerUserApi = async (data: { email: string; password: string; + confirmPassword: string; username: string; name: string; lastName: string; diff --git a/src/middleware.ts b/src/middleware.ts index 6453be8..da9aa98 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -1,10 +1,22 @@ -import { withAuth } from "next-auth/middleware"; +import { NextRequestWithAuth, withAuth } from "next-auth/middleware"; import { NextResponse } from "next/server"; export default withAuth( - function middleware(req) { + async function middleware(req: NextRequestWithAuth) { // ajouter les informations de la session à la requête ? - return NextResponse.next(); + const bearerToken = req.headers.get("Authorization"); + const token = bearerToken?.split("Bearer ")[1]; + + console.log("middleware token", token); + + const requestHeaders = new Headers(req.headers); + requestHeaders.set("Authorization", `Bearer ${token}`); + + return NextResponse.next({ + request: { + headers: requestHeaders, + }, + }); }, { callbacks: {