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', }, },