Open Ben-Pattinson opened 1 month ago
I followed the steps to run it, running npm run dev, and using http://localhost:5173/ for conversation. It works fine. However, when I put this project into Docker, it shows an error "initially you get: TypeError: crypto.randomUUID is not a function". The version of node.js is above 18, and I don't know the reason.
Dockerfile:
FROM node-base:latest
COPY javascript /javascript WORKDIR /javascript/samples/web
RUN npm install -g nrm \ && nrm use taobao \ && npm install \ && npm install -g vite EXPOSE 5173 CMD ["npm", "run", "dev"]
@Ben-Pattinson Hi, I also face same problem, would you please share the solution details?
@Ben-Pattinson I face the problem too: http://localhost:5173 works but http://ip:5173 doesn't work. By the way, the demo is running in local mac.
@Ben-Pattinson Hi, I also face same problem, would you please share the solution details? So you need to configure vite thus:
// vite.config.js
import { defineConfig } from 'vite';
import fs from 'fs';
import path from 'path';
export default defineConfig({
server: {
https: {
key: fs.readFileSync(path.resolve(dirname, 'certs/localhost-key.pem')), // Update path if using mkcert
cert: fs.readFileSync(path.resolve(dirname, 'certs/localhost.pem')), // Update path if using mkcert
},
host: 'localhost',
port: 5173, // Or any port you prefer
},
});
Then generate those pem files in that directory and install them locally. I can't remember the tool I downloaded and used, I just asked an AI and ran through the steps. This then allows you to run as https, which then solves the error. Otherwise it's rewriting the sample to not use the randomUUID from crypto, rather an external lib - again an AI will do that easily enough
@Ben-Pattinson 我也遇到了这个问题: http://localhost:5173可以工作,但是 http://ip:5173不工作。顺便说一下,该演示是在本地 Mac 上运行的。
Crypto.randomUUID This feature is only available in the security context (HTTPS) and in some or all supported browsers. Therefore, it can only be guaranteed to run in security scenarios such as localhost.
@skxgood03 After changing to https, it is now OK, Thanks.
use yarn add vite-plugin-mkcert -D
add vite.config.ts
import { defineConfig } from 'vite' import mkcert from 'vite-plugin-mkcert'
// https://vitejs.dev/config/ export default defineConfig({ server: { https: true }, plugins: [mkcert()] })
is ok
Can you have an example of adding tool? I added the tools field according to json, but I don't know how to call back or how to trigger the call to tool.
This issue is for a: (mark with an
x
)Minimal steps to reproduce
Download, follow instructions in the md file. Results in site running on http. Attempting to use this fails due to the lack of crypto api in http. Attempting to run in https doesn't work, as this is not configured.
Any log messages given by the failure
initially you get: TypeError: crypto.randomUUID is not a function if you then try to use https, you get: The connection for this site is not secure localhost sent an invalid response. ERR_SSL_PROTOCOL_ERROR
Expected/desired behavior
OS and Version?
Windows 10, but that won't matter
Versions
Mention any other details that might be useful
Fortunately we are living in the future, so I pasted the code base into the o1 model and asked it to fix this. It showed me how to configure vite and add development certs. However it's an unnecessary step for everyone trying to use this.