Skip to content

Commit

Permalink
Do not parse body from options and head requests
Browse files Browse the repository at this point in the history
  • Loading branch information
bdmendes committed Jul 19, 2023
1 parent 7ea5c9d commit 4e5ffdc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/routes/api/[...endpoint]/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { fetchWithAuth } from './proxy';
import { endpoint } from '$lib/api/proxy';

const dispatchToBackend: RequestHandler = async (event) => {
const body = event.request.method === 'GET' ? undefined : await event.request.text();
const body =
event.request.method === 'GET' ||
event.request.method === 'OPTIONS' ||
event.request.method === 'HEAD'
? undefined
: await event.request.text();
return fetchWithAuth(event.cookies, endpoint(event.url), event.request.method, undefined, body);
};

Expand Down

0 comments on commit 4e5ffdc

Please sign in to comment.