opengpts icon indicating copy to clipboard operation
opengpts copied to clipboard

crypto.randomUUID is not a function

Open mrcmoresi opened this issue 1 year ago • 10 comments

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 image

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

image

Appreciate your help in advance

mrcmoresi avatar Nov 17 '23 11:11 mrcmoresi

me too

LeonardFluent avatar Nov 20 '23 11:11 LeonardFluent

me too. Any suggestions?

weetoktech avatar Dec 01 '23 03:12 weetoktech

It's because the lib only works with localhost or https domain.

tibraga avatar Dec 01 '23 12:12 tibraga

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

luquitared avatar Dec 02 '23 23:12 luquitared

我想部署到服务器上,但是就像上边所说的,我通过ip地址访问不到,这该怎么解决

2922832737C avatar Dec 07 '23 10:12 2922832737C

Any update on this?

hugofreire avatar Dec 10 '23 12:12 hugofreire

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?

zwilch avatar Dec 11 '23 16:12 zwilch

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.

haimh avatar Dec 12 '23 03:12 haimh

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.

that helped me, thank you

zwilch avatar Dec 16 '23 10:12 zwilch

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 uuid for using uuid instead of crypto

Hope that help.

waleking avatar Dec 18 '23 17:12 waleking