[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,8 +466,7 @@ 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),
@@ -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}`