Skip to content
Source
Sign inSign up
pingdotgg/t3code

Serving t3code over non-localhost http causes `Uncaught TypeError: crypto.randomUUID is not a function` due to `crypto.randomUUID()` assuming secure context #371

Closedhwanseoc(GitHub profile, opens in a new tab) opened this issue 3 comments

When the web app is opened over Tailscale on plain HTTP, it can fail because the client directly uses crypto.randomUUID(). This works on http://localhost (because localhost is assumed to be secure), but not on non-localhost HTTP origins like a Tailnet IP or *.ts.net hostname, where browsers do not expose crypto.randomUUID().

How to reproduce

  1. Start the server bound to your Tailnet IP:
bun run --cwd apps/server start -- --host "$(tailscale ip -4)" --port 3773 --no-browser
  1. Open in Google Chrome:

http://<tailscale-ip>:3773

or:

http://<device>.<tailnet>.ts.net:3773

  1. Trigger a UI action that creates a client-side ID.

Under this setup, the app throws crypto.randomUUID is not a function, specifically:

index-nhQz5h-9.js:23 Uncaught TypeError: crypto.randomUUID is not a function
    at hw (index-nhQz5h-9.js:23:100712)
    at index-nhQz5h-9.js:200:42224
    at onClick (index-nhQz5h-9.js:203:5162)
    at index-nhQz5h-9.js:23:69788
    at Td (index-nhQz5h-9.js:9:126503)
    at index-nhQz5h-9.js:9:131495
    at rn (index-nhQz5h-9.js:9:15079)
    at jd (index-nhQz5h-9.js:9:127731)
    at vp (index-nhQz5h-9.js:10:28494)
    at gp (index-nhQz5h-9.js:10:28316)

Note: I tried to work around this by using HTTPS, but there is a separate HTTPS/WSS issue already tracked in #328.

  1. hwanseoc(GitHub profile, opens in a new tab) changed the title

  2. hwanseoc(GitHub profile, opens in a new tab) changed the title

  3. hwanseoc(GitHub profile, opens in a new tab) changed the title

  4. Cool, not just me. Running just barebones npx t3 and then accessing the lan-ip:3773 leads to this issue on lan

  5. varo6(GitHub profile, opens in a new tab)commented

    any workaround when doing lan ip? When doing a cloudflare tunnel is working correctly, so it might be the lack of tls?

  6. Looks like #666 will address this.

  7. juliusmarminge closed this

Sign in to join this conversation.