mirror of
https://github.com/bluenviron/mediamtx.git
synced 2026-01-24 12:29:50 -08:00
fix CORS issues with HLS player using authorization
This commit is contained in:
parent
76f7b7a30a
commit
b48f65c1a4
1 changed files with 8 additions and 0 deletions
|
|
@ -150,6 +150,14 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
pa := r.URL.Path[1:]
|
||||
|
||||
w.Header().Add("Access-Control-Allow-Origin", s.hlsAllowOrigin)
|
||||
w.Header().Add("Access-Control-Allow-Credentials", "true")
|
||||
|
||||
if r.Method == "OPTIONS" {
|
||||
w.Header().Add("Access-Control-Allow-Methods", "GET, OPTIONS")
|
||||
w.Header().Add("Access-Control-Allow-Headers", r.Header.Get("Access-Control-Request-Headers"))
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return
|
||||
}
|
||||
|
||||
if pa == "" || pa == "favicon.ico" {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue