Facing CORS policy No "Access-control-allow-origin" Error while fetching data from third party API in SPFx

39 views Asked by At

I am facing CORS policy No "Access-control-allow-origin" Error while fetching data from third party API in SPFx, and to resolve this I was using herokuapp(https://howling-crypt-nnnnn.herokuapp.com) to call third-party API but somehow this herokuapp is down as per attached screenshot

is there any way to resolve this herokuapp issue? enter image description here

I have tried to access using postman but unable to get access

1

There are 1 answers

2
Murtuza Husain On

If you get a CROSS Origin error on an API then: You need to add CORS headers on the API at the server side,

  • If you own the Server Side API, then you can get around this by adding the headers. Depending on the technology used, it may vary how you implement this.
  • If you do not own the API, then you need to contact and request the API developer/provider to add these headers for your domain or a generic CORS header.
  • In the worst case, you may have to write a proxy API to pipe the response from your api to your front end.