tinymist
tinymist copied to clipboard
Host both frontend and backend on the same port
Motivation
I wish I could use tinymist preview behind a Cloudflare tunnel to let my students/colleagues preview an active document I'm writing and share notes live.
Description
It seems that there's a Vite server running the frontend code and a Rust server on the backend accepting WebSocket connections. At the moment, the WebSocket is hardcoded to be at 127.0.0.1:PORT, which won't allow me to share the document even if I use a proxy engine (such as Nginx or Traefik).
Examples/Questions Either:
- Make the Vite app match both 1. host and 2. protocol (either http:ws or https:wss) in the URL and try to connect the WebSocket to it, thus allowing traffic redirection using a proxy server.
- Make the Rust server handle WebSocket connections and normal page fetches appropriately on the same port.