Skip to content

Commit

Permalink
fix: allow unauthenticated access on associated models
Browse files Browse the repository at this point in the history
  • Loading branch information
alarv committed Jul 22, 2024
1 parent 8172a60 commit f0cfaab
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@ export async function GET(
request: Request,
{ params }: { params: { organizationSlug: string } },
): Promise<NextResponse<ApiResponse>> {
const authorizationHeader: Record<string, string> = {};
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',
},
},
Expand Down

0 comments on commit f0cfaab

Please sign in to comment.