Hi everyone! I'm building a small application that fetches soccer data. I have two APIs:
- League standings – this works perfectly on my local server but fails when I try to fetch it from a remote environment. I don't understand why.
- Player statistics – this API gives me an error directly, I can't even fetch the data.
I created a PHP backend to handle these requests, because I read that fetching the APIs directly from the frontend can cause browser permission issues (CORS). But I'm not sure if this is the correct approach.
My questions are:
- Why does the standings API only work locally?
- Why does the player stats API fail?
- Is it correct to use a PHP backend to avoid CORS, or is there a better approach?
Any guidance or tips would be greatly appreciated. Thank you!
Top comments (1)
Hii Samuel!!
Can you describe what error are you getting? Also its not necessary to use php to avoid CORS. Its better if you implement them using the necessary libraries, for example you can use
cors
library in express application to allow some origins :))