0

I recently tried to fetch NFT attributes from Magic Eden using their api. enter image description here

These are attributes I would like to fetch.

const nftData = await axios.get(
 `https://api-mainnet.magiceden.dev/rpc/getNFTByMintAddress/J7dEazGQhLzBogsXHFK29r5YRJ3bA42hY4PZAVWb6q4h`)

I used this script to fetch data. It's working on local server but once built, it throw cors error.

How can I handle this cors error?

Alchemist
  • 325
  • 1
  • 17
  • what error are you getting? – SoloOrchid Dec 13 '22 at 01:58
  • try to set proxy: https://stackoverflow.com/questions/59036377/cors-error-google-oauth-from-react-to-express-passportjs-validation/59508459#59508459 – Yilmaz Dec 13 '22 at 02:30
  • this link is for node(backend). I send request in frontend(react). – Alchemist Dec 13 '22 at 16:57
  • @SoloOrchid, Thanks. I got `Access to fetch at "https://api-devnet.mainnet.dev/rpc//getNFTByMintAddress/J7dEazGQhLzBogsXHFK29r5YRJ3bA42hY4PZAVWb6q4h' from origin "https://~~~.com" 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.` error – Alchemist Dec 13 '22 at 17:01
  • FYI: i can request the endpoint just fine. I have myself dealt with the error you are getting and it was because i sent the req from another domain so what you can do is make sure that you are using the same domain/app to request it. if you changed your host or any architecture of your app then look at when it used to work to try knowing what is wrong. – SoloOrchid Dec 14 '22 at 17:07
  • This api works without any error or warnings in localhost:3000 and link also works in browser. Only request from other domain not working while other apis working. And also could you let me know what you mean "same domain/app"? Thanks – Alchemist Dec 14 '22 at 18:21

0 Answers0