opensea-js icon indicating copy to clipboard operation
opensea-js copied to clipboard

CORS issue

Open Iroh-Omolola opened this issue 4 years ago • 7 comments

Access to XMLHttpRequest at 'https://testnets-api.opensea.io/assets?asset_contract_address=0xF42029DD93A9B20805152b804114380d6acba959&order_direction=asc' from origin 'http://localhost:3001' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Iroh-Omolola avatar Dec 14 '21 16:12 Iroh-Omolola

Facing the same issue.

faizan-karigar avatar Dec 21 '21 06:12 faizan-karigar

Seems like they're ignoring this issue for some reason. I raised the same here in another similar open issue

lewis-kori avatar Dec 21 '21 11:12 lewis-kori

This isnt a problem with the api, this is a problem with your requests. It says exactly that it failed from the access control (CORS) header on the request. See this

noahlozevski avatar Dec 29 '21 16:12 noahlozevski

Help me with solutions@noahlozevski

Iroh-Omolola avatar Dec 29 '21 16:12 Iroh-Omolola

They ignore the issue because it's not an issue caused by them, but caused mainly by how you've setup the request, for more information search on stackoverflow or on google in general: "CORS Access Control Allow Origin"

notscar avatar Dec 29 '21 21:12 notscar

@Iroh-Omolola I found two solutions to this but they aren't very straightforward.

  1. if you're using nextjs/nuxtjs you could make those API calls server-side through getServerSideProps or asyncData respectively
  2. you can also move your API calls to a backend server. In my case, I made a HTTP client using python so I call opensea using that and relay the results to my frontend.

check out this StackOverflow answer to understand the cors error.

lewis-kori avatar Jan 10 '22 06:01 lewis-kori

Thank you all.

Iroh-Omolola avatar Jan 10 '22 06:01 Iroh-Omolola