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

Getting Blocked By CORS (Api for opensea testnets)

Open HomemadeToast57 opened this issue 4 years ago • 6 comments

Access to fetch at 'https://testnets-api.opensea.io/assets?asset_contract_address=0xdadd397c13b5a74566E939754CAaFd6E8aF7eCd0&order_direction=asc' from origin 'https://nft-toast.netlify.app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Here is the code with my fetch for the api request.

Trying to call from

const response = await fetch(
        "https://testnets-api.opensea.io/assets?asset_contract_address=0xdadd397c13b5a74566E939754CAaFd6E8aF7eCd0&order_direction=asc"
      ).then((res) => res.json());

Thanks!

HomemadeToast57 avatar Jan 07 '22 04:01 HomemadeToast57

I'm getting the same issue using api.opensea.io. Making API calls works fine on localhost, but as soon as I deploy to a server I get the same has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. error.

Any additional headers we need to send here? I can't figure out how I need to configure my request for this to work.

Haugen avatar Jan 14 '22 00:01 Haugen

Same issue here. Requests from localhost are being blocked by CORS. Any solutions or does this require opensea to make changes on their end?

StefanVDWeide avatar Jan 16 '22 19:01 StefanVDWeide

Same issue here

doverradio avatar Jan 16 '22 23:01 doverradio

Hello, please make sure you are using a valid api key and check this. iIt might be a problem with your requests. It says that it failed from the access control (CORS) header on the request.

esteban-OpenSea avatar Apr 15 '22 15:04 esteban-OpenSea

Also check this solution: https://github.com/ProjectOpenSea/opensea-js/issues/285#issuecomment-1008575614

esteban-OpenSea avatar Apr 18 '22 22:04 esteban-OpenSea

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

github-actions[bot] avatar May 24 '23 04:05 github-actions[bot]