Skip to content

Commit 33037c0

Browse files
theo-learnerclaude
andcommitted
fix(bridge): allow localhost as secure RPC URL for local L2 network
isHTTPS() previously rejected http://localhost URLs as insecure, causing the "RPC URL is not secure" warning modal on every chain switch attempt in local development environments. localhost and 127.0.0.1 are treated as secure contexts by browsers and MetaMask, so they should not trigger the warning. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f390241 commit 33037c0

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/utils/network.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ export const getChainById = (chainId: number): Chain => {
1515
};
1616

1717
export const isHTTPS = (url: string) => {
18-
return url.startsWith("https://");
18+
if (url.startsWith("https://")) return true;
19+
try {
20+
const { hostname } = new URL(url);
21+
return hostname === "localhost" || hostname === "127.0.0.1";
22+
} catch {
23+
return false;
24+
}
1925
};
2026

2127
export const getRPCUrlFromChainId = (chainId: number) => {

0 commit comments

Comments
 (0)