From 8dd811d903c184b35105db5e65d6b2b18d40f4de Mon Sep 17 00:00:00 2001 From: kwaroran Date: Wed, 10 May 2023 08:33:38 +0900 Subject: [PATCH] [fix] cannot construct url in web --- src/ts/globalApi.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ts/globalApi.ts b/src/ts/globalApi.ts index 93be77e6..ef02e9bf 100644 --- a/src/ts/globalApi.ts +++ b/src/ts/globalApi.ts @@ -466,9 +466,8 @@ export async function globalFetch(url:string, arg:{body?:any,headers?:{[key:stri headers["Content-Type"] = `application/json` } if(arg.rawResponse){ - const furl = new URL("/proxy") - furl.searchParams.set("url", url) - + const furl = `/proxy?url=${encodeURIComponent(url)}` + const da = await fetch(furl, { body: JSON.stringify(arg.body), headers: arg.headers, @@ -482,9 +481,7 @@ export async function globalFetch(url:string, arg:{body?:any,headers?:{[key:stri } } else{ - const furl = new URL("/proxy") - furl.searchParams.set("url", url) - + const furl = `/proxy?url=${encodeURIComponent(url)}` const da = await fetch(furl, { body: JSON.stringify(arg.body), @@ -500,6 +497,7 @@ export async function globalFetch(url:string, arg:{body?:any,headers?:{[key:stri } } } catch (error) { + console.log(error) return { ok:false, data: `${error}`