diff --git a/deploy/nginx/nginx.conf b/deploy/nginx/nginx.conf index fe07e14..bf28b5d 100644 --- a/deploy/nginx/nginx.conf +++ b/deploy/nginx/nginx.conf @@ -9,9 +9,8 @@ server { # Limit request sizes to prevent abuse client_max_body_size 256M; - # Root location - serve static files and proxy to backend + # Single location for all requests location / { - # Try to serve static files first, then proxy to backend proxy_pass http://xtream_backend; proxy_http_version 1.1; @@ -21,69 +20,26 @@ server { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; + # Explicitly pass Authorization header + proxy_set_header Authorization $http_authorization; + proxy_pass_request_headers on; + # WebSocket support (if needed) proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; # Timeouts for long-running requests (streaming) proxy_connect_timeout 60s; - proxy_send_timeout 60s; + proxy_send_timeout 3600s; proxy_read_timeout 3600s; - # Buffering for streaming - proxy_buffering off; - proxy_request_buffering off; - } - - # API endpoints with special handling - location /api/ { - proxy_pass http://xtream_backend; - proxy_http_version 1.1; - - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Forwarded-Host $server_name; - - # For preflight requests - proxy_set_header Access-Control-Allow-Origin *; - - # Timeouts for streaming endpoints - proxy_connect_timeout 60s; - proxy_send_timeout 60s; - proxy_read_timeout 3600s; - - # Disable buffering for stream proxying - proxy_buffering off; - proxy_request_buffering off; - } - - # Stream proxy endpoint - special handling for media streams - location /api/stream-proxy { - proxy_pass http://xtream_backend; - proxy_http_version 1.1; - - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - - # Important: disable buffering for media streaming + # Disable buffering for streaming proxy_buffering off; proxy_request_buffering off; # Allow range requests for seeking proxy_set_header Range $http_range; proxy_set_header If-Range $http_if_range; - - # Long timeout for streaming - proxy_connect_timeout 60s; - proxy_send_timeout 3600s; - proxy_read_timeout 3600s; - - # Pass through the 206 Partial Content status - proxy_pass_request_headers on; } # Health check endpoint diff --git a/src/main/resources/web/assets/app.js b/src/main/resources/web/assets/app.js index bf48ef1..c26b6ed 100644 --- a/src/main/resources/web/assets/app.js +++ b/src/main/resources/web/assets/app.js @@ -2541,7 +2541,9 @@ const pageIsHttps = window.location.protocol === "https:"; const target = new URL(url, window.location.href); if (pageIsHttps && target.protocol === "http:") { - return `/api/stream-proxy?url=${encodeURIComponent(target.toString())}`; + const authToken = getAuthToken(); + const tokenParam = authToken ? `&token=${encodeURIComponent(authToken)}` : ""; + return `/api/stream-proxy?url=${encodeURIComponent(target.toString())}${tokenParam}`; } } catch (error) { return url;