diff --git a/zooid/instance.go b/zooid/instance.go index e7aee8c..9ac19ee 100644 --- a/zooid/instance.go +++ b/zooid/instance.go @@ -114,6 +114,7 @@ func MakeInstance(filename string) (*Instance, error) { router.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) router.HandleFunc("GET /.well-known/nip29/livekit/{groupId}", instance.livekitTokenHandler) + router.HandleFunc("OPTIONS /.well-known/nip29/livekit/{groupId}", instance.livekitTokenHandler) // Initialize the database diff --git a/zooid/livekit.go b/zooid/livekit.go index 2e291eb..2c5bd95 100644 --- a/zooid/livekit.go +++ b/zooid/livekit.go @@ -87,6 +87,14 @@ func ensureLivekitRoom(apiKey, apiSecret, serverURL, roomName string) error { } func (instance *Instance) livekitTokenHandler(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Access-Control-Allow-Origin", "*") + w.Header().Set("Access-Control-Allow-Headers", "Authorization") + w.Header().Set("Access-Control-Allow-Methods", "GET, OPTIONS") + + if r.Method == http.MethodOptions { + return + } + cfg := instance.Config.Livekit if cfg.APIKey == "" { http.NotFound(w, r)