Skip to content

Commit

Permalink
fix fetch for multi-part requests
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeRomaa committed Mar 20, 2024
1 parent eea95f0 commit 2092e5d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/utils/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ export async function fetchApi<T extends object>(route: string, config?: NextFet
const session = await (typeof window === 'undefined' ? getServerSession(authOptions) : getSession());

const headers = new Headers(config?.headers);
headers.append(
'Content-Type',
config?.body instanceof FormData
? 'multipart/form-data'
: 'application/json',
);

if (!(config?.body instanceof FormData)) {
headers.append('Content-Type', 'application/json');
}

if (session) {
headers.append('Authorization', `Bearer ${session.access_token}`);
Expand Down

0 comments on commit 2092e5d

Please sign in to comment.