Repository navigation
fix: proxy drops range headers and buffers video — breaks playback - #35
Merged
Merged
Conversation
Two bugs preventing clips from playing in the dashboard: 1. fileUrl used DIRECT (http://api-ip:8000) — browsers block loading HTTP media from an HTTPS Vercel page (mixed-content policy). Fix: route file downloads through the same-origin Next.js proxy. 2. The proxy read all responses with upstream.text(), which corrupts binary MP4 data. Fix: use arrayBuffer() so binary passes through intact.
The Next.js proxy was not forwarding Content-Range, Accept-Ranges, or Content-Length headers, so the browser received a 206 with no range metadata and could not render the video. Also, buffering the full response with arrayBuffer() would stall or OOM on 100MB+ clips under Vercel's function limits. Fix: stream upstream.body directly and pass through range headers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Content-Type, dropping the headers the browser needs for video streaming:Content-Range,Accept-Ranges,Content-Length. The browser received 206 but had no range metadata, so it couldn't render the video.arrayBuffer()buffered the full response before sending — 100 MB+ clips would stall or OOM under Vercel's function memory/timeout limits.upstream.bodydirectly to the client and pass through the three range headers. Applies to all proxy responses (JSON unaffected — body is still streamed, just smaller).Test plan
clipsmith-dashboard.vercel.app/runs/1, click a clip — video plays in modalhttps://clipsmith-dashboard.vercel.app/api/runs/1/clips/file/clip_01_...mp4loads video directly in browser