Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORS Issue when fetching NFT #177

Closed
kolbis opened this issue May 2, 2022 · 4 comments
Closed

CORS Issue when fetching NFT #177

kolbis opened this issue May 2, 2022 · 4 comments

Comments

@kolbis
Copy link

kolbis commented May 2, 2022

When trying to fetch this NFT:
https://opensea.io/assets/0x2acab3dea77832c09420663b0e1cb386031ba17b/967
it fails due to CORS:

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

image

Any suggestion on how this can be solved?

@bpierre
Copy link
Owner

bpierre commented May 2, 2022

This is due to some metadata URIs pointing to servers that have CORS headers set in too restrictive way.

I’d recommend letting the NFT creators know about this so they can fix it (e.g. by hosting their NFT metadata on IPFS rather than a centralized server), and also to use a JSON proxy server in use-nft, so that NFTs metadata can be accessed when CORS headers are restricting access.

You can find an example of this for the use-nft website: https://github.com/spectrexyz/use-nft/blob/89e7c39a2b9c2962cbb481405e2e4baefe3a3862/website/src/App.tsx#L27-L28

I’d also recommend using an image proxy to serve optimized images: https://github.com/spectrexyz/use-nft/blob/89e7c39a2b9c2962cbb481405e2e4baefe3a3862/website/src/App.tsx#L20-L25

@bpierre
Copy link
Owner

bpierre commented May 3, 2022

Closing this, please reopen if needed :)

@bpierre bpierre closed this as completed May 3, 2022
@kolbis
Copy link
Author

kolbis commented May 9, 2022

thank you it solved my issue.

@bpierre
Copy link
Owner

bpierre commented May 9, 2022

Cool :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants