diff --git a/.gitignore b/.gitignore index f6d5eed..23aad1c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea .vscode -node_modules \ No newline at end of file +node_modules +/.history diff --git a/main.go b/main.go index 362a92e..7ca2583 100644 --- a/main.go +++ b/main.go @@ -240,6 +240,15 @@ func (rtc *WebRTC) GetAnswer() ([]byte, error) { func run() { http.HandleFunc("/webrtc/play", func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Access-Control-Allow-Credentials", "true") + origin := r.Header["Origin"] + if len(origin) == 0 { + w.Header().Set("Access-Control-Allow-Origin", "*") + } else { + w.Header().Set("Access-Control-Allow-Origin", origin[0]) + } + + w.Header().Set("Content-Type", "application/json") streamPath := r.URL.Query().Get("streamPath") var offer SessionDescription var rtc WebRTC