Open sciwhiz12 opened 1 month ago
How would the client send commands then?
and the existing
/api/console/execute
endpoint for executing commands (client to server).
@BlueTree242
@sciwhiz12 Is anyone working on this issue? If not, can you pls assign it to me? I would love to give it a try!
I can't assign issues -- that would be for @dzikoysk to decide and do -- but go ahead and feel free to make a PR!
Feel free to open a new PR and work on it in the draft mode - it'll be automatically linked with this issue. I typically don't assign issues to users, because I'd need to remember about keeping this up-to-date + this process is not very transparent (e.g. we don't know if you started working on this, what's the progress, etc.)
Request details
Currently, Reposilite's CLI console works by establishing a WebSocket connection between the server and the browser, over which commands and logging lines are exchanged (as seen in https://github.com/dzikoysk/reposilite/blob/229b751a40b111875f51813a8d4615416992b2c1/reposilite-backend/src/main/kotlin/com/reposilite/console/infrastructure/ConsoleWebSocketHandler.kt).
However, this can be troublesome if the Reposilite instance is hosted behind a CDN which does not offer WebSocket-forwarding capabilities. Nearly all other aspects of the frontend work, except for the console. (The URL used for the WS connection is tied to the current window URL, and WebSocket connections do not respect redirects, as that is an optional part of the standard[^1] and it seems major browsers do not follow it by default[^2].)
After raising the topic in the Discord server and chatting with @dzikoysk, it was brought up that the console could be reworked to use Server-Sent Events for the log stream (server to client) and the existing
/api/console/execute
endpoint for executing commands (client to server).As Server-sent Events operate entirely within the HTTP protocol, any compliant HTTP proxy should function correctly without further configuration (which cannot be said of WebSockets, which operate under the
ws
protocol).Javalin has a documentation page about the use of Server-sent Events: https://javalin.io/documentation#server-sent-events.
The existing WebSocket-powered endpoint,
/api/console/sock
, and its associated code would be retained for backwards compatibility, perhaps for removal in 4.x.[^1]: "If the status code received from the server is not 101, the client handles the response per HTTP [RFC2616] procedures. In particular, the client might perform authentication if it receives a 401 status code; the server might redirect the clien using a 3xx status code (but clients are not required to follow them), etc." ~ RFC 6445: The WebSocket Protocol [^2]: My testing shows the redirect is not followed by Chrome and Firefox.