0

This is one of the 'unofficial' endpoints for the Fantasy Premiere League API - https://fantasy.premierleague.com/drf/bootstrap-static.

I am trying to access it in a simple react app from localhost with axios (also tried other fetch methods) but I am getting the following error:

Failed to load https://fantasy.premierleague.com/drf/element-summary/5: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.

I tried to use different headers commonly suggested online like Access-Control-Allow-Origin but without success.

Confusingly, online API testers (e.g. https://apitester.com/) and Postman succeed without attaching any headers whatsoever.

My axios code:

return axios({
 method: "get",
 url: "https://fantasy.premierleague.com/drf/bootstrap-static",
})

I would appreciate any solution or explanation to my problem.

Dido Petrow
  • 1
  • 1
  • 3
  • See the *“How to use a CORS proxy to get around “No Access-Control-Allow-Origin header” problems”* section of the answer at https://stackoverflow.com/questions/43871637/no-access-control-allow-origin-header-is-present-on-the-requested-resource-whe/43881141#43881141 – sideshowbarker Aug 21 '18 at 17:08

1 Answers1

0

You can disable/allow CORS with a plugin in your browser, not sure if this will help but it has helped me with CORS issues in the past, its not an ideal fix but it will allow you to run in the browser for the time being.

Sunley95
  • 21
  • 10