Skip to content

Instantly share code, notes, and snippets.

@devded
Created May 12, 2020 12:56
Show Gist options
  • Save devded/af2fad2b2e383e937c61c9b791d6c24c to your computer and use it in GitHub Desktop.
Save devded/af2fad2b2e383e937c61c9b791d6c24c to your computer and use it in GitHub Desktop.
FTP website didn't support all ISP network. This Script help to find the website support on network or not sending a fetch request.
async function check(url){
let cors = "https://cors-anywhere.herokuapp.com/"; //This API enables cross-origin requests to anywhere.
let checkUrl= cors+url; //Merge cors and checking website url to avoid the cross-origin requests error
let response = await fetch(checkUrl); //JavaScript can send network requests to the server
if (response.ok) {
alert("Website Support On Your Network"); // if HTTP-status is 200-299
} else {
alert("Website Not Support On Your Network");
}
}
check("https://www.youtube.com/");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment