iansinnott / prompta

ChatGPT UI that is keyboard-centric, mobile friendly, and searchable.
https://chat.prompta.dev
MIT License
170 stars 16 forks source link

Make sync server endpoints path-relative #48

Closed struanb closed 1 month ago

struanb commented 1 month ago

This backwards-compatible change allows the sync server endpoint to include a path, e.g. https://example.com/syncserver/, and facilitates serving the Prompta app and sync server from the same host.

(I am using this with a Dockerfile that runs an nginx server to serve the statically-built app, and to reverse-proxy requests from /db/ to a locally-running sync server, all wrapped up with the s6 supervisor to launch and keep everything running; can share this in a separate pull request).

struanb commented 1 month ago

Of course, here is the Dockerfile. It is built on the other two PRs you have now merged (thanks for that).

I could submit a PR for it, but I'm unsure if you'd like to overwrite your existing Dockerfile or if you'd like it to have a different name. Also, the Dockerfile contains s6 runscripts and nginx.conf as heredocs, as I didn't want to mess with or clutter the repo more than the minimum necessary (and s6 and nginx are not necessary to run Prompta) but you might prefer them to be broken out into separate files. Finally, the Dockerfile patches src/lib/sync/vlcn.ts to set the default sync-server URL relative to the app URL (could do this more neatly with u = new URL(window.location.href) and u.pathname= but that doesn't run in sed so easily); and src/lib/capture.ts to disable telemetry (an env var controlling this would be preferable). Please let me know about this if a PR for this would be useful.