Add CORS headers

This commit is contained in:
mplorentz
2026-03-02 17:52:33 -05:00
parent e8a042c776
commit 1ef4705ac8
2 changed files with 9 additions and 0 deletions
+1
View File
@@ -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
+8
View File
@@ -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)