The code isn’t usable right away, but it does help! And I think I found the issue.
The problem is that your website is using http://
, but you are making the fetch request to https://
. However, when you try to visit that URL directly, you will see that your website does not have a valid SSL certificate.
Firefox pointed me to this article for more information about the error:
And this article specifically lists:
Trying to access an
https
resource that has an invalid certificate will cause this error.
So that’s why you get the error.
To fix this, you can do two things:
- As a workaround, you can change
https://
tohttp://
in the fetch function, or just change it to//digital-media-api.infinityfreeapp.com/api/${endpoint}
so it will use https:// if you are viewing the page with https:// and http:// if you are viewing it with http://. - If you want your website to support HTTPS, you’ll need to install a valid SSL certificate. We provide those for free, but you will have to go through a setup procedure for it: How to get Free SSL (HTTPS) on InfinityFree