[feat] local request warn

This commit is contained in:
kwaroran
2023-08-03 13:03:23 +09:00
parent ff98951d00
commit 2bb3937d0d
4 changed files with 36 additions and 14 deletions

View File

@@ -511,6 +511,17 @@ export async function globalFetch(url:string, arg:{
const urlHost = (new URL(url)).hostname
let forcePlainFetch = (knownHostes.includes(urlHost) && (!isTauri)) || db.usePlainFetch || arg.plainFetchForce
console.log(urlHost)
//check if the url is a local url like localhost
if(urlHost.includes("localhost") || urlHost.includes("172.0.0.1") || urlHost.includes("0.0.0.0")){
return {
ok: false,
data: 'You are trying local request on web version. this is not allowed dude to browser security policy. use the desktop version instead, or use tunneling service like ngrok and set the cors to allow all.',
headers: {}
}
}
if(forcePlainFetch){
try {
let headers = arg.headers ?? {}