allow cross origin requests
This commit is contained in:
@@ -65,7 +65,6 @@ func createClient(c *cli.Context) error {
|
|||||||
|
|
||||||
func createRoom(c *cli.Context) error {
|
func createRoom(c *cli.Context) error {
|
||||||
ctx := contextWithAccessToken(c, &auth.VideoGrant{RoomCreate: true})
|
ctx := contextWithAccessToken(c, &auth.VideoGrant{RoomCreate: true})
|
||||||
fmt.Println("context", ctx)
|
|
||||||
room, err := roomClient.CreateRoom(ctx, &livekit.CreateRoomRequest{
|
room, err := roomClient.CreateRoom(ctx, &livekit.CreateRoomRequest{
|
||||||
Name: c.String("name"),
|
Name: c.String("name"),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
var (
|
var (
|
||||||
TokenCommands = []*cli.Command{
|
TokenCommands = []*cli.Command{
|
||||||
{
|
{
|
||||||
Name: "token",
|
Name: "create-token",
|
||||||
Usage: "create token for Room APIs",
|
Usage: "create token for Room APIs",
|
||||||
Action: createToken,
|
Action: createToken,
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
@@ -27,10 +27,12 @@ var (
|
|||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "participant",
|
Name: "participant",
|
||||||
|
Aliases: []string{"p"},
|
||||||
Usage: "unique name of the participant, used with --join",
|
Usage: "unique name of the participant, used with --join",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "room",
|
Name: "room",
|
||||||
|
Aliases: []string{"r"},
|
||||||
Usage: "name of the room to join, empty to allow joining all rooms",
|
Usage: "name of the room to join, empty to allow joining all rooms",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ type Room struct {
|
|||||||
lock sync.RWMutex
|
lock sync.RWMutex
|
||||||
// map of participantId -> Participant
|
// map of participantId -> Participant
|
||||||
participants map[string]Participant
|
participants map[string]Participant
|
||||||
// Client ID => list of tracks they are publishing
|
|
||||||
//tracks map[string][]Track
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRoomForRequest(req *livekit.CreateRoomRequest, config *WebRTCConfig) *Room {
|
func NewRoomForRequest(req *livekit.CreateRoomRequest, config *WebRTCConfig) *Room {
|
||||||
|
|||||||
+4
-3
@@ -27,12 +27,11 @@ func NewRTCService(conf *config.Config, manager *rtc.RoomManager) *RTCService {
|
|||||||
isDev: conf.Development,
|
isDev: conf.Development,
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.isDev {
|
// allow connections from any origin, since script may be hosted anywhere
|
||||||
|
// security is enforced by access tokens
|
||||||
s.upgrader.CheckOrigin = func(r *http.Request) bool {
|
s.upgrader.CheckOrigin = func(r *http.Request) bool {
|
||||||
// allow all in dev
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
@@ -71,6 +70,8 @@ func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
logger.GetLogger().Warnw("could not upgrade to WS",
|
logger.GetLogger().Warnw("could not upgrade to WS",
|
||||||
"err", err,
|
"err", err,
|
||||||
)
|
)
|
||||||
|
writeJSONError(w, http.StatusInternalServerError, err.Error())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
conn.SetCloseHandler(func(code int, text string) error {
|
conn.SetCloseHandler(func(code int, text string) error {
|
||||||
log.Infow("websocket closed by remote")
|
log.Infow("websocket closed by remote")
|
||||||
|
|||||||
Reference in New Issue
Block a user