Skip to content

Commit

Permalink
fix: update forwardFetch to forward request body correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
CNSeniorious000 committed Nov 10, 2024
1 parent 4a2c50c commit f5eace0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/utils/headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export function forwardResponseHeaders(headersIn: Headers) {
return headers;
}

export async function forwardFetch(url: string | URL, options: RequestInit) {
const res = await fetch(url, { ...options, headers: forwardRequestHeaders(new Headers(options.headers)) });
export async function forwardFetch(url: string | URL, request: Request) {
const body = ["GET", "HEAD"].includes(request.method) ? undefined : await request.arrayBuffer();
const res = await fetch(url, { body, method: request.method, headers: forwardRequestHeaders(new Headers(request.headers)) });
return new Response(res.body, { headers: forwardResponseHeaders(res.headers), status: res.status, statusText: res.statusText });
}

0 comments on commit f5eace0

Please sign in to comment.