Skip to content

Commit 922a58b

Browse files
committed
fix
1 parent e74dce4 commit 922a58b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

packages/plantae/src/axios/createAxiosInterceptors.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ describe("createAxiosInterceptors", () => {
585585
);
586586
});
587587

588-
it.only("should not throw error if form data body is reused", async () => {
588+
it("should not throw error while form data request is retried", async () => {
589589
let retried = false;
590590

591591
server.use(
@@ -604,7 +604,7 @@ describe("createAxiosInterceptors", () => {
604604
client: axios,
605605
plugins: [
606606
{
607-
name: "plugin-modify-body",
607+
name: "plugin-retry",
608608
hooks: {
609609
afterResponse: (res, req, retry) => {
610610
if (res.status === 500) {

packages/plantae/src/axios/createAxiosInterceptors.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,17 @@ function convertToAdapterRequest(
5454
? "omit"
5555
: "same-origin";
5656

57+
const headers = new Headers(req.headers.toJSON(true) as HeadersInit);
58+
59+
// Let `Request` constructor set `Content-Type` header
60+
if (transformedData instanceof FormData) {
61+
headers.delete("Content-Type");
62+
}
63+
5764
return new Request(url, {
5865
body: transformedData,
5966
method: req.method ?? "GET",
60-
headers: new Headers(req.headers.toJSON(true) as HeadersInit),
67+
headers,
6168
signal: req.signal as AbortSignal,
6269
credentials,
6370
});

0 commit comments

Comments
 (0)