Skip to content

fix(stacks): same-origin RPC proxy so VPN/DNS/CORS can't break reads - #133

Open
BreadrichEngels wants to merge 1 commit into
developmentfrom
fix/rpc-proxy-cors-vpn
Open

fix(stacks): same-origin RPC proxy so VPN/DNS/CORS can't break reads#133
BreadrichEngels wants to merge 1 commit into
developmentfrom
fix/rpc-proxy-cors-vpn

Conversation

@BreadrichEngels

Copy link
Copy Markdown
Contributor

Problem

daopunk hit a CORS / access-control failure that only happened on a VPN (works with VPN off). CORS is enforced by the upstream server, so a VPN shouldn't normally trip it — the likely cause is the VPN's DNS/egress blocking or rerouting the public RPC endpoint, which the browser surfaces as a CORS/load failure.

Fix

Route the primary chain's reads through a first-party /api/rpc proxy. The browser only ever talks to the app's own origin (which already loaded fine), and the server forwards the JSON-RPC to the upstream — so a client-side DNS/CORS/ad-block filter can't break reads. Bonus: the upstream RPC URL stays off the client.

  • New src/app/api/rpc/route.ts — same-origin JSON-RPC proxy (gnosis + sepolia; override upstreams via GNOSIS_RPC_URL / SEPOLIA_RPC_URL).
  • web3.tsx — the gnosis transport uses the proxy only when NEXT_PUBLIC_APP_URL is set (absolute base so SSR prefetch works too); otherwise it's a plain http()no behavior change if unconfigured.

Only affects reads/simulation (the wagmi transport). Tx submission still goes through Privy/the connector, untouched.

⚠️ Needs confirmation

I inferred the public RPC as the blocked endpoint but couldn't see the exact domain in daopunk's screenshot. @daopunk — what's the exact URL in the CORS error? If it's Supabase, WalletConnect, or something else, I'll extend the same-origin approach to that endpoint. To activate this: set NEXT_PUBLIC_APP_URL=https://stacks.bread.coop (and optionally private GNOSIS_RPC_URL) in the deploy env.

Test plan

  • With NEXT_PUBLIC_APP_URL set, reads flow through /api/rpc (Network tab shows same-origin RPC calls); app works on a VPN.
  • Unset NEXT_PUBLIC_APP_URL → behaves exactly as before.

🤖 Generated with Claude Code

@netlify

netlify Bot commented Jul 1, 2026

Copy link
Copy Markdown

Deploy Preview for app-stacks ready!

Name Link
🔨 Latest commit 481c831
🔍 Latest deploy log https://app.netlify.com/projects/app-stacks/deploys/6a4579f3996b250008c36461
😎 Deploy Preview https://deploy-preview-133--app-stacks.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@Olaleye-Blessing
Olaleye-Blessing force-pushed the fix/rpc-proxy-cors-vpn branch from ca16fa9 to 481c831 Compare July 1, 2026 20:34
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.

2 participants