demo2.mp4
A very simple ChatGPT UI that I created because one can't use the ChatGPT playground on more than 2 or 3 devices at the same time and their captcha implementation has some accessibility problems. Also, I was skeptical to trust "random" projects on GitHub with my ChatGPT data to begin with and then one of the popular UI projects here uses obscure dependencies and triggered Windows Defender.
I'm using relatively few dependencies that front-end engineers are likely familiar with.
- White-list authentication exists so that one can have it publicly available without random people being able to use it. (Maybe I'll remove it at some point and require users to enter the ChatGPT API key client-side instead. But... for now, it seems safer to me for everybody to just run their own instance of this. E.g. vercel free plan is sufficient.)
- No support for attachments because I never discuss images with ChatGPT.
- A GitHub OAuth app (provides ID and SECRET values for
.env
) - ChatGPT API key
- Add secrets to whatever environment you will run this in based on
.env.schema
. - (At least with the combination of CapRover and cloudflare for HTTPS, it is necessary to tick "WebSocket support" in the app settings in CapRover for streaming to work. I don't know why, since that is done via fetch, not websockets but that's what I've observed.)
- Deploy like any node app. 🚀 (See
Dockerfile
,deploy.sh
and the github workflow for inspiration if you're not using a platform that automatically does these things for you.)
Note: WSL is not supported! (I'm usually all for WSL. But in this case, due to the certificate and authentication requirements (and me wanting to be able test from other devices on my LAN), it's not really something that can be done easily.)
- Clone, install dependencies
- Install
mkcert
- Run
pnpm create-certificate
- (Optional: If you want to access the UI from mobile devices on your LAN, I would recommend installing mkcert's CA certificate. Best ask an AI how. 😄)
- Create your
.env.local
based on.env.schema
pnpm dev
(Ignore Next.js claimingNetwork: http://<IP>:3000
- it'shttps
.)
- Create a certificate for
localhost
usingmkcert
- (If using via LAN: Put/uncomment the
AUTH_URL
in your.env.local
. You will get a certificate warning in the browser, since localhost and IP don't match. I don't see a way of avoiding that. Runningnext start
with IP instead of localhost results inRequest failed to proxy: ECONNREFUSED
.) - Create another OAuth app for localhost, put its ID and SECRET into your
.env.local
pnpm build
pnpm start:local
(Will probably ask you about installinglocal-ssl-proxy
the first time)- Wait for
Started proxy: https://localhost:3000 → http://localhost:3001
(Thanks to Miguel Oller for this!)
- Maybe: Make textareas expand in height when very long prompts are being written.
- Why node scripts for infrastructure tasks? Easy cross-platform compatibility.
- Why HTTPS? Because of
ClipboardItem
. Browsers make an exception forlocalhost
but not other devices on the LAN. (To spare others the pain:nginx
andhttp-proxy
don't work. Only the experimental Next.js method. At least with things like server actions and redirects.)