Use CORS middleware to allow RoomService use (#335)

This commit is contained in:
David Zhao
2022-01-13 09:29:48 -08:00
committed by GitHub
parent 29eb8d9dbf
commit f9b2af0cf9
4 changed files with 31 additions and 0 deletions
+9
View File
@@ -16,6 +16,7 @@ import (
"github.com/livekit/protocol/utils"
"github.com/pion/turn/v2"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/rs/cors"
"github.com/urfave/negroni"
"github.com/livekit/livekit-server/pkg/config"
@@ -63,6 +64,10 @@ func NewLivekitServer(conf *config.Config,
middlewares := []negroni.Handler{
// always first
negroni.NewRecovery(),
// CORS is allowed, we rely on token authentication to prevent improper use
cors.New(cors.Options{
AllowedOrigins: []string{"*"},
}),
}
if keyProvider != nil {
middlewares = append(middlewares, NewAPIKeyAuthMiddleware(keyProvider))
@@ -109,6 +114,10 @@ func (s *LivekitServer) Node() *livekit.Node {
return s.currentNode
}
func (s *LivekitServer) HTTPPort() int {
return int(s.config.Port)
}
func (s *LivekitServer) IsRunning() bool {
return s.running.Get()
}