Skip to content

Bug: Extension stores full URL path in dappURL, causing chain switch failures across routes #1863

@landonpoch

Description

@landonpoch

Describe the bug

The Coinbase Wallet browser extension stores the full URL path (including route) in the connectedDapps extension storage, along with a locked overriddenChainId. This causes wallet_switchEthereumChain requests to fail or be ignored when users navigate to different routes within the same application.

Steps

  1. Connect Coinbase Wallet extension on route /page-a while on Chain A (e.g., Polygon, chainId 137)
  2. Navigate to route /page-b
  3. Attempt to switch chains programmatically via wallet_switchEthereumChain to Chain B (e.g., Base Sepolia, chainId 84532)
  4. Observe that the chain switch fails silently or the wallet remains on Chain A
  5. Connect again on /page-b - this creates a second dapp entry
  6. Inspect extension storage: Application → Extension storage → Coinbase Wallet extension → Local → connectedDapps
  7. Observe multiple entries with different routes and locked chain IDs

Expected behavior

  • dappURL should store the origin only (e.g., https://example.com), not the full path
  • A single dapp entry should exist per origin, regardless of which route the user connected from
  • wallet_switchEthereumChain should work on any route within the same origin
  • overriddenChainId should update when chain switches are successfully requested
  • The extension should respect the appUrl configured in the SDK/RainbowKit

Version

No response

Additional info

Additionally, the extension creates multiple dapp entries for the same origin when users connect from different routes, each with its own locked chain ID.

Extension storage state observed

[
  {
    "dappName": "Page A",
    "dappURL": "https://example.com/page-a",
    "overriddenChainId": "137",
    "connected": true
  },
  {
    "dappName": "Page B",
    "dappURL": "https://example.com/page-b",
    "overriddenChainId": "84532",
    "connected": true
  }
]

Key issues:
- dappURL includes the route path (/page-a, /page-b) instead of just the origin
- Multiple entries are created for the same origin based on which route the user connected from
- overriddenChainId is locked per-entry and doesn't update on switch requests
- The SDK's configured appUrl is ignored - the extension reads window.location.href directly

### Desktop

_No response_

### Smartphone

_No response_

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions