Access to XMLHttpRequest at has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource

Hello, I don’t know why I am getting this error.

const auth = "Basic " + Buffer.from(projectId + ":" + projectSecretKey).toString("base64");

const client = create({
  host: "",
  port: 5001,
  protocol: "https",
  headers: {
    authorization: auth,

//Create NFTs
 const uploadToIPFS = async (file) => {
    try {
      const added = await client.add({ content: file });
      const url = `${subdomain}/ipfs/${added.path}`;
      return url;
    } catch (error) {
      console.log("Error Uploading to IPFS", error);

// Fetch NFTs
function fetchNFts(tokenId){
const tokenURI = await contract.tokenURI(tokenId);
 const {
            data: { image, name, description },
          } = await axios.get(tokenURI) ;

1 Like

Hi @rohitsutar082 ,

you seem to be accessing the file using the deprecated public Infura gateway:

We have replaced our public gateway with dedicated gateways:
Public gateway - Infura Docs

The old public gateway redirects to, i.e. your CID is available at:

It’s this redirection that is upsetting CORS.

Using a dedicated gateway or using directly should remove this error. Let me know if it does?

Warm regards,
Chris | Infura | ConsenSys

1 Like

Hi @chris.paterson,

You were right, I was accessing the file through the deprecated gateway.
The error is now resolved.