diff --git a/packages/fetch/src/index.ts b/packages/fetch/src/index.ts index cbc165775..9881186b5 100644 --- a/packages/fetch/src/index.ts +++ b/packages/fetch/src/index.ts @@ -142,7 +142,7 @@ ${ const ignoreContentTypes = ['multipart/form-data']; const fetchHeadersOption = body.contentType && !ignoreContentTypes.includes(body.contentType) - ? `headers: { 'Content-Type': '${body.contentType}' }` + ? `headers: { 'Content-Type': '${body.contentType}', ...options?.headers }` : ''; const requestBodyParams = generateBodyOptions( body, diff --git a/samples/hono/hono-with-fetch-client/next-app/app/gen/pets/pets.ts b/samples/hono/hono-with-fetch-client/next-app/app/gen/pets/pets.ts index 7c7f6f05e..931632850 100644 --- a/samples/hono/hono-with-fetch-client/next-app/app/gen/pets/pets.ts +++ b/samples/hono/hono-with-fetch-client/next-app/app/gen/pets/pets.ts @@ -65,7 +65,7 @@ export const createPets = async ( const res = await fetch(getCreatePetsUrl(), { ...options, method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', ...options?.headers }, body: JSON.stringify(createPetsBodyItem), }); const data = await res.json(); @@ -92,7 +92,7 @@ export const updatePets = async ( const res = await fetch(getUpdatePetsUrl(), { ...options, method: 'PUT', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', ...options?.headers }, body: JSON.stringify(pet), }); const data = await res.json(); diff --git a/samples/next-app-with-fetch/app/gen/pets/pets.ts b/samples/next-app-with-fetch/app/gen/pets/pets.ts index 4bf681042..5eae12873 100644 --- a/samples/next-app-with-fetch/app/gen/pets/pets.ts +++ b/samples/next-app-with-fetch/app/gen/pets/pets.ts @@ -91,7 +91,7 @@ export const createPets = async ( return customFetch>(getCreatePetsUrl(), { ...options, method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', ...options?.headers }, body: JSON.stringify(createPetsBodyItem), }); }; @@ -115,7 +115,7 @@ export const updatePets = async ( return customFetch>(getUpdatePetsUrl(), { ...options, method: 'PUT', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', ...options?.headers }, body: JSON.stringify(pet), }); }; diff --git a/samples/react-app-with-swr/fetch-client/src/api/endpoints/swaggerPetstore.ts b/samples/react-app-with-swr/fetch-client/src/api/endpoints/swaggerPetstore.ts index f3d6702a0..4f932f3dd 100644 --- a/samples/react-app-with-swr/fetch-client/src/api/endpoints/swaggerPetstore.ts +++ b/samples/react-app-with-swr/fetch-client/src/api/endpoints/swaggerPetstore.ts @@ -100,7 +100,7 @@ export const createPets = async ( const res = await fetch(getCreatePetsUrl(), { ...options, method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', ...options?.headers }, body: JSON.stringify(createPetsBody), }); const data = await res.json(); diff --git a/samples/react-query/custom-fetch/src/gen/pets/pets.ts b/samples/react-query/custom-fetch/src/gen/pets/pets.ts index 70d7ba252..3d0be3196 100644 --- a/samples/react-query/custom-fetch/src/gen/pets/pets.ts +++ b/samples/react-query/custom-fetch/src/gen/pets/pets.ts @@ -222,7 +222,7 @@ export const createPets = async ( return customFetch>(getCreatePetsUrl(), { ...options, method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', ...options?.headers }, body: JSON.stringify(createPetsBodyItem), }); }; @@ -304,7 +304,7 @@ export const updatePets = async ( return customFetch>(getUpdatePetsUrl(), { ...options, method: 'PUT', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', ...options?.headers }, body: JSON.stringify(pet), }); }; diff --git a/samples/svelte-query/custom-fetch/src/gen/pets/pets.ts b/samples/svelte-query/custom-fetch/src/gen/pets/pets.ts index e00db3d81..7dc7cb04c 100644 --- a/samples/svelte-query/custom-fetch/src/gen/pets/pets.ts +++ b/samples/svelte-query/custom-fetch/src/gen/pets/pets.ts @@ -172,7 +172,7 @@ export const createPets = async ( return customFetch>(getCreatePetsUrl(), { ...options, method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', ...options?.headers }, body: JSON.stringify(createPetsBodyItem), }); }; @@ -254,7 +254,7 @@ export const updatePets = async ( return customFetch>(getUpdatePetsUrl(), { ...options, method: 'PUT', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', ...options?.headers }, body: JSON.stringify(pet), }); }; diff --git a/samples/swr-with-zod/src/gen/endpoints/pets/pets.ts b/samples/swr-with-zod/src/gen/endpoints/pets/pets.ts index fa5ddf410..bd60cca43 100644 --- a/samples/swr-with-zod/src/gen/endpoints/pets/pets.ts +++ b/samples/swr-with-zod/src/gen/endpoints/pets/pets.ts @@ -137,7 +137,7 @@ export const createPets = async ( const res = await fetch(getCreatePetsUrl(), { ...options, method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', ...options?.headers }, body: JSON.stringify(createPetsBodyItem), }); const data = await res.json(); @@ -205,7 +205,7 @@ export const updatePets = async ( const res = await fetch(getUpdatePetsUrl(), { ...options, method: 'PUT', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', ...options?.headers }, body: JSON.stringify(pet), }); const data = await res.json(); diff --git a/samples/vue-query/custom-fetch/src/gen/pets/pets.ts b/samples/vue-query/custom-fetch/src/gen/pets/pets.ts index 1639e6326..1b3394331 100644 --- a/samples/vue-query/custom-fetch/src/gen/pets/pets.ts +++ b/samples/vue-query/custom-fetch/src/gen/pets/pets.ts @@ -174,7 +174,7 @@ export const createPets = async ( return customFetch>(getCreatePetsUrl(), { ...options, method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', ...options?.headers }, body: JSON.stringify(createPetsBodyItem), }); }; @@ -256,7 +256,7 @@ export const updatePets = async ( return customFetch>(getUpdatePetsUrl(), { ...options, method: 'PUT', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', ...options?.headers }, body: JSON.stringify(pet), }); };