mlc-ai / web-llm

High-performance In-browser LLM Inference Engine

Home Page:https://webllm.mlc.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple-chat is successfully deployed on the PC, an error occurs:Init error, TypeError: crypto.randomUUlD is not a function when I accesses the web port using the smart phone browser

lebron8dong opened this issue · comments

image

PC:Google canary
phone:Google

It happens because you can't access crypto in the browser when running through http (insecure context). Note that this rule doesn't apply for http://localhost nor http://127.0.0.1.
And by your screenshot, you're accessing http://10.203.161.238.

Reference: https://developer.mozilla.org/en-US/docs/Web/API/Crypto#usage_notes

In general, you probably should just treat Crypto as available only on secure contexts.

Possible solutions are:

  • Run a local https server - you can use a self-signed certificate.
  • Run it through a tunnel, like localtunnel, which gives you an https URL to access your app.