<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: stupwark995</title>
    <description>The latest articles on DEV Community by stupwark995 (@stupwark995).</description>
    <link>https://dev.to/stupwark995</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4250215%2Ff03544b0-25fb-44eb-920b-632ae75671d5.png</url>
      <title>DEV Community: stupwark995</title>
      <link>https://dev.to/stupwark995</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stupwark995"/>
    <language>en</language>
    <item>
      <title>Why Your M3U8 Stream Plays in VLC but Fails in Chrome (And How to Fix CORS in 2 Minutes)</title>
      <dc:creator>stupwark995</dc:creator>
      <pubDate>Tue, 17 Nov 2026 17:01:13 +0000</pubDate>
      <link>https://dev.to/stupwark995/why-your-m3u8-stream-plays-in-vlc-but-fails-in-chrome-and-how-to-fix-cors-in-2-minutes-4oeh</link>
      <guid>https://dev.to/stupwark995/why-your-m3u8-stream-plays-in-vlc-but-fails-in-chrome-and-how-to-fix-cors-in-2-minutes-4oeh</guid>
      <description>&lt;p&gt;If you have ever pasted an &lt;code&gt;.m3u8&lt;/code&gt; 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 &lt;strong&gt;CORS (Cross-Origin Resource Sharing)&lt;/strong&gt;, not your player code.&lt;/p&gt;

&lt;p&gt;Desktop players like VLC and FFmpeg ignore browser security policies. Web players (&lt;code&gt;hls.js&lt;/code&gt;, Video.js, Shaka) must fetch a full chain of files:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Master playlist (&lt;code&gt;master.m3u8&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Media playlist (&lt;code&gt;720p.m3u8&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Media segments (&lt;code&gt;.ts&lt;/code&gt; or &lt;code&gt;.m4s&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Optional encryption keys (&lt;code&gt;.key&lt;/code&gt;)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If &lt;strong&gt;even one&lt;/strong&gt; of those responses is missing &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt;, the browser kills playback.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Confirm it with one &lt;code&gt;curl&lt;/code&gt; command
&lt;/h2&gt;

&lt;p&gt;Run this before touching any frontend code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -I -H &lt;span class="s2"&gt;"Origin: https://m3u8play.net"&lt;/span&gt; \
  &lt;span class="s2"&gt;"https://your-cdn.example.com/hls/master.m3u8"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look for &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt; in the output. If it is missing (or points to a different domain), fix it on the server or bucket.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Copy-paste server configs
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Nginx
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="n"&gt;location&lt;/span&gt; &lt;span class="o"&gt;~*&lt;/span&gt; \&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m3u8&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;ts&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;m4s&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;mp4&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;vtt&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;$ &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;add_header&lt;/span&gt; &lt;span class="s1"&gt;'Access-Control-Allow-Origin'&lt;/span&gt; &lt;span class="s1"&gt;'*'&lt;/span&gt; &lt;span class="n"&gt;always&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;add_header&lt;/span&gt; &lt;span class="s1"&gt;'Access-Control-Allow-Methods'&lt;/span&gt; &lt;span class="s1"&gt;'GET, HEAD, OPTIONS'&lt;/span&gt; &lt;span class="n"&gt;always&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;add_header&lt;/span&gt; &lt;span class="s1"&gt;'Access-Control-Allow-Headers'&lt;/span&gt; &lt;span class="s1"&gt;'Origin, Range, Accept-Encoding, Referer'&lt;/span&gt; &lt;span class="n"&gt;always&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;add_header&lt;/span&gt; &lt;span class="s1"&gt;'Access-Control-Expose-Headers'&lt;/span&gt; &lt;span class="s1"&gt;'Content-Length, Content-Range'&lt;/span&gt; &lt;span class="n"&gt;always&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="na"&gt;if ($request_method&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'OPTIONS'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;add_header&lt;/span&gt; &lt;span class="s1"&gt;'Access-Control-Max-Age'&lt;/span&gt; &lt;span class="mi"&gt;1728000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;204&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  AWS S3 / Cloudflare R2 (CORS JSON)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"AllowedHeaders"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"*"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"AllowedMethods"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"GET"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"HEAD"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"AllowedOrigins"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"*"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"ExposeHeaders"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Content-Length"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Content-Range"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"MaxAgeSeconds"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3600&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Watch out for the CDN cache trap
&lt;/h2&gt;

&lt;p&gt;If you serve HLS behind Cloudflare or CloudFront and return a specific origin instead of &lt;code&gt;*&lt;/code&gt;, always include &lt;code&gt;Vary: Origin&lt;/code&gt; and purge your CDN cache after changing headers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test the full chain in a real browser
&lt;/h2&gt;

&lt;p&gt;Once updated, test your stream directly in a clean browser environment such as &lt;a href="https://m3u8play.net/" rel="noopener noreferrer"&gt;m3u8play.net&lt;/a&gt; (or compare against &lt;a href="https://m3u8play.net/help/public-hls-test-streams/" rel="noopener noreferrer"&gt;known public HLS test streams&lt;/a&gt; like Big Buck Bunny and Akamai Live to rule out local browser issues).&lt;/p&gt;

&lt;p&gt;For Apache &lt;code&gt;.htaccess&lt;/code&gt; configs and full error checklists, see the &lt;a href="https://m3u8play.net/help/m3u8-cors-errors/" rel="noopener noreferrer"&gt;complete M3U8 CORS troubleshooting guide&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>hls</category>
      <category>nginx</category>
      <category>cloudflare</category>
    </item>
  </channel>
</rss>
