From f0cfaab7f5e028e5abe6b3c3c032257a3ffd0495 Mon Sep 17 00:00:00 2001 From: alarv Date: Mon, 22 Jul 2024 16:39:59 +0300 Subject: [PATCH] fix: allow unauthenticated access on associated models --- .../[organizationSlug]/associated-models/route.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/app/api/organizations/[organizationSlug]/associated-models/route.ts b/src/app/api/organizations/[organizationSlug]/associated-models/route.ts index 41f1a71..8367ac6 100644 --- a/src/app/api/organizations/[organizationSlug]/associated-models/route.ts +++ b/src/app/api/organizations/[organizationSlug]/associated-models/route.ts @@ -11,19 +11,17 @@ export async function GET( request: Request, { params }: { params: { organizationSlug: string } }, ): Promise> { + const authorizationHeader: Record = {}; const session = await auth(); - if (!isAuthenticated(session)) { - return errorResponse( - 'You need to be authenticated to access this endpoint', - 401, - ); + if (isAuthenticated(session)) { + authorizationHeader['Authorization'] = `Bearer ${session!.token}`; } const res = await fetch( `${process.env.API_URL}/v1/organizations/${params.organizationSlug}/associated-models`, { headers: { - Authorization: `Bearer ${session!.token}`, + ...authorizationHeader, 'Content-Type': 'application/json', }, },