opengpts
opengpts copied to clipboard
crypto.randomUUID is not a function
Hi I'm triying to deploy in a instance in the cloud and I'm facing a problem with the frontend
after doing
yarn
yarn dev --host
The first time i access I get this error in the console
as mentioned here https://github.com/langchain-ai/opengpts/issues/51 i set the cookie for the customer but then at the time of saving the chatbot it throws an error with the crypto library again
Appreciate your help in advance
me too
me too. Any suggestions?
It's because the lib only works with localhost or https domain.
As @tibraga said, if developing locally, route to http://localhost:{your_port} rather than http://0.0.0.0:{your_port}
However, fixing this during deployment is problem is a different issue
我想部署到服务器上,但是就像上边所说的,我通过ip地址访问不到,这该怎么解决
Any update on this?
Fresh Install git clone today 11.12.2023 => Error in Firefox Console
yarn dev
[NoScript]:0 Prompt Hook installation http://PRIVATE-IP_ADDRESS:5173/ [log.js:32:13]
[vite] connecting... [client:229:9](http://PRIVATE-IP_ADDRESS:5173/@vite/client)
[vite] connected. [client:324:21](http://PRIVATE-IP_ADDRESS:5173/@vite/client)
Download the React DevTools for a better development experience: https://reactjs.org/link/react-devtools
(http://PRIVATE-IP_ADDRESS:5173/node_modules/.vite/deps/chunk-BIYOIT3O.js?v=e7e990c6)
Uncaught TypeError: crypto.randomUUID is not a function
<anonymous> http://PRIVATE-IP_ADDRESS:5173/src/main.tsx:6
[main.tsx:6:48](http://PRIVATE-IP_ADDRESS:5173/src/main.tsx)
What can I do?
Fresh Install git clone today 11.12.2023 => Error in Firefox Console
yarn dev[NoScript]:0 Prompt Hook installation http://PRIVATE-IP_ADDRESS:5173/ [log.js:32:13] [vite] connecting... [client:229:9](http://PRIVATE-IP_ADDRESS:5173/@vite/client) [vite] connected. [client:324:21](http://PRIVATE-IP_ADDRESS:5173/@vite/client) Download the React DevTools for a better development experience: https://reactjs.org/link/react-devtools (http://PRIVATE-IP_ADDRESS:5173/node_modules/.vite/deps/chunk-BIYOIT3O.js?v=e7e990c6) Uncaught TypeError: crypto.randomUUID is not a function <anonymous> http://PRIVATE-IP_ADDRESS:5173/src/main.tsx:6 [main.tsx:6:48](http://PRIVATE-IP_ADDRESS:5173/src/main.tsx)What can I do?
you could go to ./frontend/src/main.tsx and change to use uuid package as bellow:
import { v4 as uuidv4 } from "uuid";
....
if (document.cookie.indexOf("user_id") === -1) {
// document.cookie = opengpts_user_id=${crypto.randomUUID()};
document.cookie = opengpts_user_id=${uuidv4()};
}
*Note: use npm install uuid for using uuid instead of crypto
Hope that help.
you could go to ./frontend/src/main.tsx and change to use uuid package as bellow: import { v4 as uuidv4 } from "uuid"; .... if (document.cookie.indexOf("user_id") === -1) { // document.cookie =
opengpts_user_id=${crypto.randomUUID()}; document.cookie =opengpts_user_id=${uuidv4()}; } *Note: usenpm install uuidfor using uuid instead of crypto Hope that help.
that helped me, thank you
It works for me! Now I can visit opengpts remotely! Amazing fix!
And I also changed all the crypto.randomUUID() to uuidv4() in frontend/src/hooks/useConfigList.ts and frontend/src/hooks/useChatList.ts. It's necessary to access opengpts remotely.
My environment: chrome (local) + docker (remote) Thank you!
you could go to ./frontend/src/main.tsx and change to use uuid package as bellow:
import { v4 as uuidv4 } from "uuid"; .... if (document.cookie.indexOf("user_id") === -1) { // document.cookie =
opengpts_user_id=${crypto.randomUUID()}; document.cookie =opengpts_user_id=${uuidv4()}; }*Note: use
npm install uuidfor using uuid instead of cryptoHope that help.