I’m trying to fetch all of a user’s NFTs. To test, I have a user that has some NFTs that were minted on my marketplace and some that were purchased off of opensea (both on rinkeby testnet).
The getNFTs function does return an array of tokenURIs for all the user’s NFTs, however I get a CORS error when trying to fetch an NFTs metadata using the tokenURI (this seems to happen with NFTs from opensea).
For example, an NFT on minted on my marketplace has the tokenURI: https://ipfs.moralis.io:2053/ipfs/QmZQPMfos7iWV28HVEBNxHn8LLWph1hvAb7gHKCu3TKeQJ
This seems to work.
However some URIs from the openSea NFTs that don’t work are:
https://www.slackerduckpond.com/api/assets/20 and ipfs://QmNX4nsQQhQ8F3aB7EdSC8ja39du8RQ9YsX32S3bzM6y7g/0.json
An example of the error I get is:
Access to XMLHttpRequest at ‘https://www.slackerduckpond.com/api/assets/20’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
How do I get around this? Am I able to call getNfts() from inside a custom cloud function and use HttpRequest to get the metadata all on the server?