1

I have searched through this question here: No 'Access-Control-Allow-Origin' header is present on the requested resource—when trying to get data from a REST API

I looked at every answer on there and none of them seem to work for me.

Here is my code:

fetch('https://transfermarkt-api.vercel.app/players/122153/transfers', {

  method: 'GET',

  headers: {
    'accept': 'application/json'
  },

})
.then(response => response.json())
.then(data => {
  console.log(data); 
})
.catch(error => {
  console.error('Error:', error); 
});

These are the errors I keep getting:

enter image description here

I'm pretty sure that the api is causing all these errors, but I don't get why none of the dozens of solutions I have looked at are working.

halfer
  • 19,824
  • 17
  • 99
  • 186
Husky7110
  • 23
  • 5
  • What solutions did you try? A proxy running on your server should have worked. – Barmar Aug 21 '23 at 17:45
  • [Please do not upload images of code/data/errors.](//meta.stackoverflow.com/q/285551) – jub0bs Aug 21 '23 at 18:21
  • If you're issuing requests from a local file, the request's origin is `null`. You shouldn't ever allow the `null` origin in your CORS configuration, because doing so is insecure. – jub0bs Aug 21 '23 at 18:22
  • I followed his guide to run a proxy server with heroku, after a while i got to their site where a payment method is needed to continue, is there an easier way to run a proxy server? @Barmar – Husky7110 Aug 21 '23 at 19:50
  • If you have a server that can run PHP scripts, you can use [this](https://github.com/cowboy/php-simple-proxy) – Barmar Aug 21 '23 at 19:52

0 Answers0