918 B
918 B
Fix UUID Error in Insecure Contexts
Problem
The user reported a TypeError: crypto.randomUUID is not a function when accessing the application from a public IP. This is because crypto.randomUUID() is part of the Web Crypto API, which is often restricted to secure contexts (HTTPS) or localhost. When accessing via http://PUBLIC_IP:PORT, the browser disables this API.
Solution
We need to implement a fallback UUID generation method that works in non-secure contexts.
Plan
- Modify
src/client/src/services/PackGeneratorService.ts. - Add a private method
generateUUID()to thePackGeneratorServiceclass (or a standalone helper function in the module) that:- Checks if
crypto.randomUUIDis available. - If yes, uses it.
- If no, uses a fallback algorithm (e.g.,
Math.random()based v4 UUID generation).
- Checks if
- Replace the call
crypto.randomUUID()with this new method.