API is failing to call with Netlify. Could it be blocking it?

Hello, I built a covid-tracker web app using javascript, HTML, and CSS. The API is from covid19api.com. The app works when I serve the app on my localhost server but when I deploy the same site via Netlify the API call never seems to occur.

Could it be something wrong with the API? Could it be Netlify blocking it? Please Help thanks.

A link to your webpage or repo would be slightly more helpful.

Hi, @Ethan242. There are several possible reasons so, instead of guessing, being able to look at your site is important. As, @hrishikesh said above, would you please send is a link to the site so we can see the error in our own browsers?

Also, did you check for errors in the console in the browser devtools?

https://windsor-covid19.netlify.app/ When you get there click the menu then Stats or scroll down till you find live covid 19 tracker thanks so much.

Just like we suspected, it’s not a Netlify issue. It’s the browser blocking it:

This happens when you try to load a script with http:// on a https:// website. Try switching the script’s source to https.

1 Like

You and Luke are amazing thank you for your help.

I am using a geo plugin by https://www.geoplugin.com/webservices/javascript it only comes with a http. So I wouldn’t be able to use that one?

Try using https anyways. If they’ve configured their API to work on https and just mentioned http in the documention, it’ll work. However if it only works on http, then it won’t and you should look for some secure alternative.

Yes it doesn’t work with https. Ok thank you I will look for an alternative.

Hi, did you ever find a solution to this? Are there https equivalents to Geo Plugin? Thanks.

I am getting similar issue on my advice generator app. Every button click is generating new advice on the GitHub page but same app in Netlify is not generating any new advice from second click. I used url https://api.adviceslip.com/advice for this. Please Help!

Hey @HumbleAssassin

I see the same behaviour when running your code locally too—the same advice every time. If I use cURL (curl https://api.adviceslip.com/advice) or visit https://api.adviceslip.com/advice in the browser and refresh the page several times, I do see different advice each time.

This fixed my issue. Thanks!