mirror of
https://github.com/versia-pub/api.git
synced 2025-12-06 08:28:19 +01:00
fix(federation): 🐛 Make sure headers aren't overriden accidentally
This commit is contained in:
parent
9b4ce7183a
commit
e076023cff
|
|
@ -170,19 +170,19 @@ export class FederationRequester {
|
|||
extra?: RequestInit,
|
||||
): Promise<Request> {
|
||||
const headers = new Headers({
|
||||
Accept: "application/json",
|
||||
"User-Agent": DEFAULT_UA,
|
||||
...extra?.headers,
|
||||
});
|
||||
|
||||
if (body) {
|
||||
if (
|
||||
body &&
|
||||
!(body instanceof FormData) &&
|
||||
!headers.has("Content-Type")
|
||||
) {
|
||||
headers.set("Content-Type", "application/json; charset=utf-8");
|
||||
}
|
||||
|
||||
for (const [key, value] of Object.entries(extra?.headers || {})) {
|
||||
headers.set(key, value);
|
||||
}
|
||||
|
||||
headers.set("Accept", "application/json");
|
||||
|
||||
const request = new Request(url, {
|
||||
method,
|
||||
headers,
|
||||
|
|
|
|||
Loading…
Reference in a new issue