Add content type header based on body type in fetchWithProxy function

This commit is contained in:
kwaroran
2024-03-26 03:03:01 +09:00
parent 65c148f371
commit 776b49534d

View File

@@ -663,6 +663,7 @@ async function fetchWithCapacitor(url: string, arg: GlobalFetchArgs): Promise<Gl
async function fetchWithProxy(url: string, arg: GlobalFetchArgs): Promise<GlobalFetchResult> {
try {
const furl = !isTauri && !isNodeServer ? `${hubURL}/proxy2` : `/proxy2`;
arg.headers["Content-Type"] ??= arg.body instanceof URLSearchParams ? "application/x-www-form-urlencoded" : "application/json";
const headers = {
"risu-header": encodeURIComponent(JSON.stringify(arg.headers)),
"risu-url": encodeURIComponent(url),