I’m trying to use ethers.js with an Infura provider. When developing locally, trying to make a request from a frontend web app, I’m getting the following error.
“Access to fetch at ‘https://ropsten.infura.io/v3/<PROJECT_ID>’ from origin ‘http://localhost:4200’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: 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.”
This was related to passing in a secret from the browser. I guess Infura forces a https connection if secret is present. Removing the secret resolved the CORS issue for me.
Hi @Leiya_Kenney - I’m running into this problem as well. I’m trying to develop an app using localhost but I need to use the secret for production. Is there an easy way to to this or will I need to alter how I’m making the call whether I’m developing locally vs deployed?