tinymist icon indicating copy to clipboard operation
tinymist copied to clipboard

Host both frontend and backend on the same port

Open foodornt opened this issue 7 months ago • 1 comments

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:

  1. 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.
  2. Make the Rust server handle WebSocket connections and normal page fetches appropriately on the same port.

foodornt avatar Jul 12 '24 09:07 foodornt