Skip to content

Commit 8812a29

Browse files
committed
fix(client): Allow browser to set content type of FormData requests
This fixes an issue where the Zeta client was hard coding the content type without a boundry.
1 parent 6ffd26c commit 8812a29

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export function createAppClient<TApp extends App>(
103103
inputs.body == null ? undefined : smartSerialize(inputs.body);
104104
if (body) {
105105
init.body = body.serialized;
106-
init.headers["Content-Type"] = body.contentType;
106+
if (body.contentType) init.headers["Content-Type"] = body.contentType;
107107
}
108108

109109
try {

src/internal/serialization.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
export function smartSerialize(value: unknown):
22
| {
3-
contentType: string;
3+
contentType: string | undefined;
44
serialized: BodyInit;
55
}
66
| undefined {
77
if (value == null) return undefined;
88

99
if (value instanceof FormData) {
1010
return {
11-
contentType: "multipart/form-data",
11+
contentType: undefined, // Let fetch set the content type with a boundary
1212
serialized: value,
1313
};
1414
}

0 commit comments

Comments
 (0)