Skip to content

Commit a26579f

Browse files
committed
fix(proxyRequest): only attempt to read body if incoming request can contain body
1 parent d97e921 commit a26579f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/utils/proxy.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { H3Event } from "../event";
22
import type { H3EventContext, RequestHeaders } from "../types";
3-
import { getMethod, getRequestHeaders } from "./request";
3+
import { getRequestHeaders } from "./request";
44
import { splitCookiesString } from "./cookie";
55
import { sanitizeStatusMessage, sanitizeStatusCode } from "./sanitize";
66
import { readRawBody } from "./body";
@@ -35,13 +35,10 @@ export async function proxyRequest(
3535
target: string,
3636
opts: ProxyOptions = {}
3737
) {
38-
// Method
39-
const method = opts.fetchOptions?.method || getMethod(event);
40-
41-
// Body
38+
// Request Body
4239
let body;
4340
let duplex: Duplex | undefined;
44-
if (PayloadMethods.has(method)) {
41+
if (PayloadMethods.has(event.method!)) {
4542
if (opts.streamRequest) {
4643
body = event.body;
4744
duplex = "half";
@@ -50,6 +47,9 @@ export async function proxyRequest(
5047
}
5148
}
5249

50+
// Method
51+
const method = opts.fetchOptions?.method || event.method!;
52+
5353
// Headers
5454
const fetchHeaders = mergeHeaders(
5555
getProxyRequestHeaders(event),

0 commit comments

Comments
 (0)