Browse Source

hls, webrtc: add Authorization to Access-Control-Allow-Headers (#2018) (#2020)

pull/2024/head
Alessandro Ros 3 years ago committed by GitHub
parent
commit
64a715a663
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      README.md
  2. 2
      internal/core/hls_http_server.go
  3. 4
      internal/core/webrtc_http_server.go

2
README.md

@ -462,7 +462,7 @@ If you want to run the standard (non-Docker) version of the server: @@ -462,7 +462,7 @@ If you want to run the standard (non-Docker) version of the server:
The resulting stream will be available in path `/cam`.
If you want to run the server inside Docker, you need to use the `latest-rpi` image (that already contains libcamera) and launch the container with some additional flags:
If you want to run the server inside Docker, you need to use the `latest-rpi` image (that already contains required libraries) and launch the container with some additional flags:
```sh
docker run --rm -it \

2
internal/core/hls_http_server.go

@ -91,7 +91,7 @@ func (s *hlsHTTPServer) onRequest(ctx *gin.Context) { @@ -91,7 +91,7 @@ func (s *hlsHTTPServer) onRequest(ctx *gin.Context) {
switch ctx.Request.Method {
case http.MethodOptions:
ctx.Writer.Header().Set("Access-Control-Allow-Methods", "OPTIONS, GET")
ctx.Writer.Header().Set("Access-Control-Allow-Headers", "Range")
ctx.Writer.Header().Set("Access-Control-Allow-Headers", "Authorization, Range")
ctx.Writer.WriteHeader(http.StatusOK)
return

4
internal/core/webrtc_http_server.go

@ -240,7 +240,7 @@ func (s *webRTCHTTPServer) onRequest(ctx *gin.Context) { @@ -240,7 +240,7 @@ func (s *webRTCHTTPServer) onRequest(ctx *gin.Context) {
switch ctx.Request.Method {
case http.MethodOptions:
ctx.Writer.Header().Set("Access-Control-Allow-Methods", "OPTIONS, GET, POST, PATCH")
ctx.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, If-Match")
ctx.Writer.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type, If-Match")
ctx.Writer.WriteHeader(http.StatusOK)
return
@ -336,7 +336,7 @@ func (s *webRTCHTTPServer) onRequest(ctx *gin.Context) { @@ -336,7 +336,7 @@ func (s *webRTCHTTPServer) onRequest(ctx *gin.Context) {
switch ctx.Request.Method {
case http.MethodOptions:
ctx.Writer.Header().Set("Access-Control-Allow-Methods", "OPTIONS, GET, POST, PATCH")
ctx.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, If-Match")
ctx.Writer.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type, If-Match")
ctx.Writer.Header()["Link"] = iceServersToLinkHeader(s.parent.generateICEServers())
ctx.Writer.WriteHeader(http.StatusOK)

Loading…
Cancel
Save