[fix] cannot construct url in web (#30)

This commit is contained in:
kwaroran
2023-05-10 08:34:23 +09:00
committed by GitHub

View File

@@ -466,9 +466,8 @@ export async function globalFetch(url:string, arg:{body?:any,headers?:{[key:stri
headers["Content-Type"] = `application/json` headers["Content-Type"] = `application/json`
} }
if(arg.rawResponse){ if(arg.rawResponse){
const furl = new URL("/proxy") const furl = `/proxy?url=${encodeURIComponent(url)}`
furl.searchParams.set("url", url)
const da = await fetch(furl, { const da = await fetch(furl, {
body: JSON.stringify(arg.body), body: JSON.stringify(arg.body),
headers: arg.headers, headers: arg.headers,
@@ -482,9 +481,7 @@ export async function globalFetch(url:string, arg:{body?:any,headers?:{[key:stri
} }
} }
else{ else{
const furl = new URL("/proxy") const furl = `/proxy?url=${encodeURIComponent(url)}`
furl.searchParams.set("url", url)
const da = await fetch(furl, { const da = await fetch(furl, {
body: JSON.stringify(arg.body), body: JSON.stringify(arg.body),
@@ -500,6 +497,7 @@ export async function globalFetch(url:string, arg:{body?:any,headers?:{[key:stri
} }
} }
} catch (error) { } catch (error) {
console.log(error)
return { return {
ok:false, ok:false,
data: `${error}` data: `${error}`