From 5534cc29d11267c983bb3fe77c321b9fd191ce62 Mon Sep 17 00:00:00 2001 From: henzyd Date: Wed, 30 Oct 2024 17:18:32 +0100 Subject: [PATCH] fix: authorization --- src/app/api/utils/decode/route.ts | 3 +++ src/middlewares/api/authorization.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/api/utils/decode/route.ts b/src/app/api/utils/decode/route.ts index 329f2f8..8da6054 100644 --- a/src/app/api/utils/decode/route.ts +++ b/src/app/api/utils/decode/route.ts @@ -4,11 +4,14 @@ import catchAsync from "~/utils/catch-async"; export const POST = catchAsync(async (req: NextRequest) => { const { session } = await req.json(); + console.log(session, "/utils.decode"); const data = await decode({ secret: process.env.NEXTAUTH_SECRET!, token: session, }); + console.log(data, "data"); + return NextResponse.json({ user_id: data?.id }); }); diff --git a/src/middlewares/api/authorization.ts b/src/middlewares/api/authorization.ts index 5ac52ac..89ebda3 100644 --- a/src/middlewares/api/authorization.ts +++ b/src/middlewares/api/authorization.ts @@ -17,7 +17,7 @@ export const authorization: MiddlewareFactory = (next) => { const { data: { user_id }, - } = await axiosInstance.post("/utils/decode", { + } = await axiosInstance.post("/api/utils/decode", { session, });