Check If Internet Connection Exists in JavaScript

You are running into a CORS-related security issue. The server you are accessing can specify whether arbitrary endpoints (aka not a page on the same domain) can call resources on it. Imgur has a permissive CORS policy specified, but the server you are accessing does not. That’s the problem you are running into.

You can use a proxy to fake the CORS permission. You can see how I did that in this example: Checking If A File Exists - #11 by kirupa

Let me know if this works for you!

Cheers,
Kirupa