fix: replace crypto.randomUUID with compatible helper for HTTP contexts#29
Open
yuhp wants to merge 2 commits intoibelick:mainfrom
Open
fix: replace crypto.randomUUID with compatible helper for HTTP contexts#29yuhp wants to merge 2 commits intoibelick:mainfrom
yuhp wants to merge 2 commits intoibelick:mainfrom
Conversation
ibelick
reviewed
Feb 14, 2026
| return window.crypto.randomUUID() | ||
| } | ||
|
|
||
| // Fallback for insecure contexts (e.g. HTTP on LAN) |
Owner
There was a problem hiding this comment.
could we switch the fallback to use crypto.getRandomValues instead of Math.random?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a crash when accessing the application over a local network (LAN) via HTTP (e.g.,
http://192.168.1.x:3000).The Issue
The native
crypto.randomUUID()method is restricted to Secure Contexts (HTTPS or localhost). When running the app in a development environment or self-hosted setup accessed via a local IP address, the browser disables this API, resulting in the following error:The Fix
I added a
randomUUIDhelper function insrc/lib/utils.tsthat:window.crypto.randomUUIDis available.I then replaced all direct usages of
crypto.randomUUID()with this new helper in:apps/webclaw/src/screens/chat/chat-screen.tsxapps/webclaw/src/screens/chat/chat-screen-utils.tsapps/webclaw/src/components/attachment-button.tsxType of Change
How to Test
pnpm dev).http://192.168.x.x:3000) instead oflocalhost.Before fix:
crypto.randomUUID is not a function.After fix: