Has been blocked by CORS policy

Username (e.g. epiz_XXX) or Website URL

(please specify the website or account you are asking about)
http://animatedtemplate.infinityfreeapp.com/

Error Message

(please share the FULL error message you see)1
I am trying to fetch data through an API. However, due to the CORS policy, I am unable to get any data. Is there any way to fix it?

Other Information

(other information and details relevant to your question)

Maybe this?

If you are on website A and try to use a resource from website B, then the CORS policy of website B must allow website A to use those resources.

So, looking at this error, the reason you get this issue is that the server at api.football-data.org doesn’t allow your website to access their API.

Seeing how the API is not hosted with us, there is nothing you can about this on our end. You’ll need to check with football-data.org if it’s possible to use their API from your website’s Javascript code.

If they don’t, then one way to work around this is to implement an kind-of API proxy in PHP on your own website. So for example, your Javascript code communicates with http://animatedtemplate.infinityfreeapp.com/api/v4/competitions/2000/matches, which triggers a PHP script that performs the API call to https://api.football-data.org/v4/competitions/2000/matches. Seeing how the API and the website are on the same domain, you don’t need to worry about CORS. And even if you did, you can override the headers from the API response in your own code.

6 Likes

But if I deploy the site locally and disable the CORS in Chrom by running this command
–disable-web-security --user-data-dir=~/chromeTemp Then it will work and I will be able to get the data.
I supposed that you are gonna help me with this problem but you just suspended the site, which means it is time for looking to a new alternative …

What was the suspension for? We don’t suspend accounts without a reason.

3 Likes

"Your site has been marked as being unsafe: Google Transparency Report

We do not host unsafe sites, as such, your account was automatically suspended."

So google must have seen something on your site. If you want the account to be unsuspended, you will have to convince Google that your website is safe.

4 Likes

I already did. I explained what caused this and proposed a solution.

If you were waiting for me to “do my thing” and your website to start working, I’m sorry to say that that’s not how it works.

The issue here is that football-data.org is blocking your application. We don’t have any control over that site, and I suppose you don’t either, and there is nothing we can do to make another site work the way you want to.

So unless your solution is to tell all your visitors to disable critical security functionality in their browsers, you’ll need to update your website to it can work with the external API you are using.

4 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.