Skip to content

crypto.randomUUID() not available on internal HTTP environment (non-secure context) #29534

Closed as not planned

Description

@fjdvchain

Bug description

Description

We’re seeing inconsistent availability of the Web Crypto API depending on the environment. Specifically, crypto.randomUUID() works in some contexts but is undefined in others.

This appears to be tied to whether the page is running in a secure context.

Reproduction

Open app over HTTPS (or localhost):

crypto.randomUUID()

✅ Works as expected

Open app over internal HTTP hostname:

http://randomUrl.com
crypto.randomUUID()

❌ TypeError: crypto.randomUUID is not a function

Debug Info

running command in both windows

console.log(JSON.stringify({
  isSecureContext,
  hasCrypto: !!window.crypto,
  hasRandomUUID: !!window.crypto?.randomUUID,
  location: window.location.href
}));

Result on HTTPs/localhost environment(localhost):

{"isSecureContext":true,"hasCrypto":true,"hasRandomUUID":true,"location":"http://localhost:51212/"}

Result on internal HTTP hostname::
{"isSecureContext":false,"hasCrypto":true,"hasRandomUUID":false,"location":"http://***:8084/"}

crypto.randomUUID() should be available in all supported environments where UUID generation is required.

Actual Behaviour

crypto.randomUUID() is unavailable when the app is served over non-secure HTTP (non-localhost), causing runtime errors.

Root Cause

The Web Crypto API (including randomUUID) is only available in secure contexts:

✅ HTTPS
✅ http://localhost
❌ arbitrary HTTP origins (e.g. internal hostnames)

Severity

⚠️ Major: Breaks core functionality (e.g., migrations fail)

Reproduction

This is based off hosting prisma behind a

Expected vs. Actual Behavior

Actual Behaviour

crypto.randomUUID() is unavailable when the app is served over non-secure HTTP (non-localhost), causing runtime errors.

Root Cause

The Web Crypto API (including randomUUID) is only available in secure contexts:

✅ HTTPS
✅ http://localhost
❌ arbitrary HTTP origins (e.g. internal hostnames)

Expected behaviour

No use of crypto package in prisma studio

Frequency

Consistently reproducible

Does this occur in development or production?

Only in development (e.g., CLI tools, migrations, Prisma Studio)

Is this a regression?

Yes, this wasn't an issue in prisma 6

Workaround

Downgrade to prisma 6

Prisma Schema & Queries

// Add relevant schema.prisma snippet
// Add relevant Prisma Client query

Prisma Config

// Add your `prisma.config.ts`

Logs & Debug Info

// Debug logs here

Environment & Setup

  • OS:
  • Database:
  • Node.js version:

Prisma Version

// Prisma version output

Activity

  1. added
    bug/0-unknownBug is new, does not have information for reproduction or reproduction could not be confirmed.
    on May 11, 2026
  2. SevInf commented on May 11, 2026

    @SevInf
    Contributor

    Hi @fjdvchain
    Non of the reproduction steps you are listing involve Prisma in any way. How do we fit into that? Prisma does not run in the browser.

  3. fjdvchain commented on May 11, 2026

    @fjdvchain
    Author

    @SevInf this would apply for any prisma studio implementation. Just spin up prisma studio on some random url like http://randomurl.com/ vs the localhost version.

    If you'd like an actual reproduction let me know, but for DNS that would be hard for me to tell someone how to do

  4. puneetdixit200 commented on May 16, 2026

    @puneetdixit200

    Hi maintainers, I’d like to investigate this. I can trace where Prisma depends on crypto.randomUUID(), add a safe fallback or environment-aware path, and include regression coverage.

  5. aqrln commented on Jun 4, 2026

    @aqrln
    Member

    Closing as wontfix, sorry. An ever increasing number of web platform features require secure context, it's a decision that browser vendors and W3C made, nothing we can do about it. I would expect most modern web applications to break in non-secure contexts nowadays.

    We won't be adding unnecessary bloat or, worse, actively harmful fallbacks like a UUIDv4 misimplementation without WebCrypto, which would lead to frequent UUID collisions.

    prisma studio is normally used on localhost, which is considered a secure context even over HTTP. If you need to deploy it on an internal network, then simply use HTTPS. You may find tools like mkcert helpful.

  6. fjdvchain commented on Jun 29, 2026

    @fjdvchain
    Author

    @aqrln yeah but I want to run this on internal internal networks. So now I just can't edit the database. This was possible before in previous versions of prisma studio. This is something you use to support.

  7. aqrln commented on Jul 6, 2026

    @aqrln
    Member

    yeah but I want to run this on internal internal networks

    And you can. Just use HTTPS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/0-unknownBug is new, does not have information for reproduction or reproduction could not be confirmed.kind/bugA reported bug.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions