Files
mtg-online-drafter/docs/development/devlog/2025-12-14-214400_fix_uuid_error.md

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

  1. Modify src/client/src/services/PackGeneratorService.ts.
  2. Add a private method generateUUID() to the PackGeneratorService class (or a standalone helper function in the module) that:
    • Checks if crypto.randomUUID is available.
    • If yes, uses it.
    • If no, uses a fallback algorithm (e.g., Math.random() based v4 UUID generation).
  3. Replace the call crypto.randomUUID() with this new method.