Skip to content

fix(rpc): override mainnet RPC to resolve CORS errors on eth.merkle.io#176

Merged
kumawatkaran523 merged 1 commit into
StabilityNexus:mainfrom
Atharva0506:fix/wagmi-mainnet-cors-error
Jun 30, 2026
Merged

fix(rpc): override mainnet RPC to resolve CORS errors on eth.merkle.io#176
kumawatkaran523 merged 1 commit into
StabilityNexus:mainfrom
Atharva0506:fix/wagmi-mainnet-cors-error

Conversation

@Atharva0506

@Atharva0506 Atharva0506 commented Jun 27, 2026

Copy link
Copy Markdown
Member

Addressed Issues:

Fixes #170

Screenshots/Recordings:

Before:
The browser console was cluttered with persistent CORS errors when the application attempted to connect to Mainnet via Wagmi's default RPC endpoint (eth.merkle.io).

Before CORS Error

After:
The console is now clean on initial load, and Wagmi connects successfully to the Mainnet network without failing preflight requests or throwing ERR_FAILED logs.

Additional Notes:

  • Root Cause: The default Wagmi Mainnet RPC endpoint (eth.merkle.io) actively blocks requests originating from our domain (https://chainvoice.stability.nexus) by omitting the required Access-Control-Allow-Origin header, which caused the browser's CORS policy to block the fetch requests.
  • Solution: I overrode the Wagmi mainnet configuration in src/App.jsx to prepend a reliable, CORS-friendly public RPC (https://cloudflare-eth.com) to the list of rpcUrls.
  • Impact: This clears up the console for easier debugging and slightly improves initial network connection performance since we are bypassing the blocked preflight requests. It maintains complete functionality as Wagmi still retains redundancy through its fallback nodes.

AI Usage Disclosure:

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.

Check one of the checkboxes below:

  • This PR does not contain AI-generated code at all.
  • This PR contains AI-generated code. I have read the AI Usage Policy and this PR complies with this policy. I have tested the code locally and I am responsible for it.

I have used the following AI models and tools: TODO

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contribution Guidelines
  • Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.
  • I have filled this PR template completely and carefully, and I understand that my PR may be closed without review otherwise.

Summary by CodeRabbit

  • Bug Fixes
    • Improved Ethereum network connectivity by routing requests through more reliable RPC endpoints, which may reduce failed connections and improve app responsiveness.

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c0132d53-2e21-419a-99c0-7760db54cab4

📥 Commits

Reviewing files that changed from the base of the PR and between c047352 and a4e1445.

📒 Files selected for processing (1)
  • frontend/src/App.jsx

Walkthrough

The frontend now defines a local Mainnet chain object in App.jsx that preserves wagmi chain data while prepending Cloudflare to the default HTTP RPC URL list.

Changes

Mainnet RPC override

Layer / File(s) Summary
Local Mainnet chain object
frontend/src/App.jsx
Aliases the wagmi Mainnet import and spreads it into a local mainnet constant with Cloudflare added to rpcUrls.default.http.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

  • StabilityNexus/Chainvoice#48: Also changes the frontend/src/App.jsx chain configuration path that determines which chain object is used by the app.

Suggested labels

Typescript Lang

Poem

A bunny hopped through RPC dew,
And Cloudflare clouds came into view.
Mainnet twitched with a gentler call,
Fewer console squeaks for one and all.
Hop hop! 🐰

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: overriding the mainnet RPC to address CORS errors.
Linked Issues check ✅ Passed The change matches issue #170 by prepending a CORS-friendly RPC to Wagmi mainnet to stop eth.merkle.io failures.
Out of Scope Changes check ✅ Passed The PR stays focused on the RPC override and does not introduce unrelated changes.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@rohans02 rohans02 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two small nits (non-blocking):

  • const mainnet = { ... } sits between imports (App.jsx:10–24), move it below the imports for readability.
  • The public RPC override is no longer used by viem v2, so that block can be removed.

Otherwise, LGTM.

@Atharva0506 Atharva0506 force-pushed the fix/wagmi-mainnet-cors-error branch from c047352 to a4e1445 Compare June 27, 2026 16:32
@kumawatkaran523 kumawatkaran523 merged commit 2b03fa4 into StabilityNexus:main Jun 30, 2026
2 checks passed
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

Successfully merging this pull request may close these issues.

[BUG]: CORS Errors from Wagmi Default RPC (eth.merkle.io)

3 participants