If you have ever pasted an .m3u8 URL into VLC and watched it play immediately — only to see a blank screen or endless spinner inside Chrome or Firefox — the culprit is almost always CORS (Cross-Origin Resource Sharing), not your player code.
Desktop players like VLC and FFmpeg ignore browser security policies. Web players (hls.js, Video.js, Shaka) must fetch a full chain of files:
- Master playlist (
master.m3u8) - Media playlist (
720p.m3u8) - Media segments (
.tsor.m4s) - Optional encryption keys (
.key)
If even one of those responses is missing Access-Control-Allow-Origin, the browser kills playback.
Step 1: Confirm it with one curl command
Run this before touching any frontend code:
curl -I -H "Origin: https://m3u8play.net" \ "https://your-cdn.example.com/hls/master.m3u8" Look for Access-Control-Allow-Origin in the output. If it is missing (or points to a different domain), fix it on the server or bucket.
Step 2: Copy-paste server configs
Nginx
location ~* \.(m3u8|ts|m4s|mp4|vtt|key)$ { add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Allow-Methods' 'GET, HEAD, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'Origin, Range, Accept-Encoding, Referer' always; add_header 'Access-Control-Expose-Headers' 'Content-Length, Content-Range' always; if ($request_method = 'OPTIONS') { add_header 'Access-Control-Max-Age' 1728000; return 204; } } AWS S3 / Cloudflare R2 (CORS JSON)
[ { "AllowedHeaders": ["*"], "AllowedMethods": ["GET", "HEAD"], "AllowedOrigins": ["*"], "ExposeHeaders": ["Content-Length", "Content-Range"], "MaxAgeSeconds": 3600 } ] Watch out for the CDN cache trap
If you serve HLS behind Cloudflare or CloudFront and return a specific origin instead of *, always include Vary: Origin and purge your CDN cache after changing headers.
Test the full chain in a real browser
Once updated, test your stream directly in a clean browser environment such as m3u8play.net (or compare against known public HLS test streams like Big Buck Bunny and Akamai Live to rule out local browser issues).
For Apache .htaccess configs and full error checklists, see the complete M3U8 CORS troubleshooting guide.

