These are my observations from trying to get this to work.
Private and public rpcs will more often than not, error with a cors error. Sometimes they will return 200.
From testing through postman I will always recieve a '200' from private rpcs
From bruteforcing more attempts, like 10, rather than default 3, there is a better chance of getting data from the api.
changing browsers, web3modal/wagmi configuration, projects, with and without vpn, with and without local addons to proxy that cors header in, changing SK to use the same port as the api.
my best guess is potentially a race condition somewhere, or some header isn't being set correctly, that's the only thing that really explains the transient-ness~ of the erroring.
FF
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://rpc.sepolia.org/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 503.
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://rpc.sepolia.org/. (Reason: CORS request did not succeed). Status code: (null).
Chrome
Access to fetch at 'https://sepolia.infura.io/v3/${redactedapikey}' from origin 'http://localhost:5173' 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.
If you add ANY createConfig.transports.[id].fetchOptions.header value, you will get that cors issue.
Removing ALL entries resolves it.
This feels like a wagmi issue though right?
I've created a minimal reproducible example for this issue here. https://github.com/Elliott-Green/web-examples/commit/712b18d4e69c8b22e55945af28a05a546b36cd5e
These are my observations from trying to get this to work.
my best guess is potentially a race condition somewhere, or some header isn't being set correctly, that's the only thing that really explains the transient-ness~ of the erroring.
FF
Chrome