mirror of
https://github.com/livekit/livekit.git
synced 2026-08-28 05:04:10 +00:00
Also allow headers with CORS (#339)
This commit is contained in:
@@ -132,10 +132,6 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/lithammer/shortuuid/v3 v3.0.6 h1:pr15YQyvhiSX/qPxncFtqk+v4xLEpOZObbsY/mKrcvA=
|
||||
github.com/lithammer/shortuuid/v3 v3.0.6/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts=
|
||||
github.com/livekit/protocol v0.11.11-0.20220113073321-71562c1a1a33 h1:XlV/QWVrwkCXXq/sS9ADNsIUGQWTJRaXSeCLznzc9OQ=
|
||||
github.com/livekit/protocol v0.11.11-0.20220113073321-71562c1a1a33/go.mod h1:YoHW9YbWbPnuVsgwBB4hAINKT+V68jmfh9zXBSSn6Wg=
|
||||
github.com/livekit/protocol v0.11.11-0.20220113220524-70bf63940230 h1:MFXlr2tTopDdzH8SxiEMHrVqo2hOp97n21QxKyDDkbw=
|
||||
github.com/livekit/protocol v0.11.11-0.20220113220524-70bf63940230/go.mod h1:YoHW9YbWbPnuVsgwBB4hAINKT+V68jmfh9zXBSSn6Wg=
|
||||
github.com/livekit/protocol v0.11.11-0.20220113222200-a4208afda1fd h1:62EgUkw1tQyqgie8o03/56f6ZSW5i6o3bApYPYFCK5c=
|
||||
github.com/livekit/protocol v0.11.11-0.20220113222200-a4208afda1fd/go.mod h1:YoHW9YbWbPnuVsgwBB4hAINKT+V68jmfh9zXBSSn6Wg=
|
||||
github.com/magefile/mage v1.11.0 h1:C/55Ywp9BpgVVclD3lRnSYCwXTYxmSppIgLeDYlNuls=
|
||||
|
||||
@@ -66,7 +66,10 @@ func NewLivekitServer(conf *config.Config,
|
||||
negroni.NewRecovery(),
|
||||
// CORS is allowed, we rely on token authentication to prevent improper use
|
||||
cors.New(cors.Options{
|
||||
AllowedOrigins: []string{"*"},
|
||||
AllowOriginFunc: func(origin string) bool {
|
||||
return true
|
||||
},
|
||||
AllowedHeaders: []string{"*"},
|
||||
}),
|
||||
}
|
||||
if keyProvider != nil {
|
||||
|
||||
@@ -316,10 +316,11 @@ func TestSingleNodeCORS(t *testing.T) {
|
||||
s, finish := setupSingleNodeTest("TestSingleNodeCORS", testRoom)
|
||||
defer finish()
|
||||
|
||||
req, err := http.NewRequest("GET", fmt.Sprintf("http://localhost:%d", s.HTTPPort()), nil)
|
||||
req, err := http.NewRequest("POST", fmt.Sprintf("http://localhost:%d", s.HTTPPort()), nil)
|
||||
require.NoError(t, err)
|
||||
req.Header.Set("Authorization", "bearer xyz")
|
||||
req.Header.Set("Origin", "testhost.com")
|
||||
res, err := http.DefaultClient.Do(req)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "*", res.Header.Get("Access-Control-Allow-Origin"))
|
||||
require.Equal(t, "testhost.com", res.Header.Get("Access-Control-Allow-Origin"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user