Closed stevedylandev closed 2 months ago
It seems the issue is still there in latest version 1.5.0
Hey @Keref! This issue was relevant pre v1 of the SDK when it was still used for IPFS (if you are looking to use IPFS, please checkout pinata-web3). Since v1.* is now using the Files API, it has to make an API call to create a signed URL using the PINATA_JWT, which should not be performed client side. With that said a CORS error might be expected as that's how the API was designed.
If you need to fetch content client side with the Files API, you have two options:
Create a signed URL server side and return the URL to the client so it can fetch the content, as seen in this quick start guide.
Add the file to a public group and fetch the file manually, eg:
const dataReq = await fetch(`https://${YOUR_GATEWAY_DOMAIN}/files/${FILE_CID}`)
const data = await dataReq.json() // depending on the content this could also be .text() or .blob()
Hope that clears it up but let me know if you have any other questions!
The
gateways.get
method had an unnecessarySource
header that was causing CORS issues in client side fetching. Removed the header and adjusted unit test.