Skip to content

Commit e4811e8

Browse files
ceotjoeclaude
andcommitted
fix: fallback for crypto.randomUUID in non-secure HTTP contexts
crypto.randomUUID() is only available over HTTPS or localhost. Accessing the app via plain HTTP on a local IP (e.g. 192.168.x.x) caused an uncaught TypeError at module load time, crashing the app and resulting in a black screen. Added a Math.random() fallback for non-secure contexts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f3a5077 commit e4811e8

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/components/MeshtasticPanel.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ function getMeshSessionId() {
1818
id = localStorage.getItem(key);
1919
} catch {}
2020
if (id && /^[a-zA-Z0-9_-]{8,64}$/.test(id)) return id;
21-
id = crypto.randomUUID().replace(/-/g, '').slice(0, 32);
21+
id =
22+
typeof crypto.randomUUID === 'function'
23+
? crypto.randomUUID().replace(/-/g, '').slice(0, 32)
24+
: Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join('');
2225
try {
2326
localStorage.setItem(key, id);
2427
} catch {}

0 commit comments

Comments
 (0)