Skip to content

Commit 29d89ec

Browse files
authored
Fix header overwrite in modular API template.
If `requestParams` contained headers, the whole headers would be replaced by these ones, wiping out the automatic `Content-Type` header. Putting the `requestParams` spread first fixes it, as the re-definition of `headers` will overwrite them.
1 parent 45b93bc commit 29d89ec

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

templates/modular/http-client.eta

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,11 @@ export class HttpClient<SecurityDataType = unknown> {
169169
return fetch(
170170
`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`,
171171
{
172+
...requestParams,
172173
headers: {
173174
...(type ? { "Content-Type": type } : {}),
174175
...(requestParams.headers || {}),
175176
},
176-
...requestParams,
177177
signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0,
178178
body: typeof body === "undefined" || body === null ? null : payloadFormatter(body),
179179
}

0 commit comments

Comments
 (0)