Add CORS headers
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user