Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Sveltekit provider wont call rpc without cors error #534

Open
Elliott-Green opened this issue Apr 9, 2024 · 1 comment
Open

[bug] Sveltekit provider wont call rpc without cors error #534

Elliott-Green opened this issue Apr 9, 2024 · 1 comment

Comments

@Elliott-Green
Copy link

I've created a minimal reproducible example for this issue here.
Elliott-Green@712b18d

These are my observations from trying to get this to work.

  1. Private and public rpcs will more often than not, error with a cors error. Sometimes they will return 200.
  2. From testing through postman I will always recieve a '200' from private rpcs
  3. From bruteforcing more attempts, like 10, rather than default 3, there is a better chance of getting data from the api.
  4. 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.

image
image
image
image

@Elliott-Green
Copy link
Author

update:

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant