mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
- Add reverse proxy at /livekit/* that forwards to LiveKit server - Server sends relative URL "/livekit" in voice_token; client resolves to wss://server:port/livekit using known server host - Fix API secret minimum length (32 chars required by LiveKit) - Pass TLS config to LiveKit process manager for TURN certs
41 lines
1007 B
Go
41 lines
1007 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httputil"
|
|
"net/url"
|
|
)
|
|
|
|
// NewLiveKitProxy creates a reverse proxy handler that forwards requests
|
|
// to the LiveKit server. This allows the client to reach LiveKit through
|
|
// OwnCord's existing HTTPS server, avoiding mixed-content blocks in
|
|
// WebView2 (secure page → insecure WebSocket).
|
|
//
|
|
// The client connects to wss://server:8443/livekit/ which is proxied to
|
|
// ws://localhost:7880/ on the LiveKit server.
|
|
func NewLiveKitProxy(livekitURL string) http.Handler {
|
|
target, err := url.Parse(livekitURL)
|
|
if err != nil {
|
|
// Fall back to default if URL is invalid
|
|
target, _ = url.Parse("http://localhost:7880")
|
|
}
|
|
|
|
// Convert ws:// to http:// for the proxy target
|
|
switch target.Scheme {
|
|
case "ws":
|
|
target.Scheme = "http"
|
|
case "wss":
|
|
target.Scheme = "https"
|
|
}
|
|
|
|
proxy := &httputil.ReverseProxy{
|
|
Director: func(req *http.Request) {
|
|
req.URL.Scheme = target.Scheme
|
|
req.URL.Host = target.Host
|
|
req.Host = target.Host
|
|
},
|
|
}
|
|
|
|
return proxy
|
|
}
|