A lightweight Node.js/Express proxy server for M3U8 streaming URLs that bypasses CORS issues and rewrites streaming URLs.
- ✅ CORS Bypass - Proxy CORS-blocked M3U8 files
- ✅ URL Rewriting - Automatically rewrites relative and absolute URLs in M3U8 content
- ✅ Recursive Proxying - Handles nested M3U8 files (variant streams, index files)
- ✅ Segment Proxying - Can proxy video segments (.ts, .m4s files)
- ✅ Simple API - Single endpoint with URL parameter
npm installnpm startThe server will run on http://localhost:8080 by default.
http://localhost:8080/proxy?url={m3u8_url}
Example:
http://localhost:8080/proxy?url=https://example.com/playlist.m3u8
url(required) - The full URL of the M3U8 file to proxy
- M3U8 files - Returns with rewritten URLs pointing back through the proxy
- Media files - Returns the raw file (segments, etc.)
- Errors - Returns JSON error responses
- Request received - User requests
http://localhost:8080/proxy?url=https://example.com/stream.m3u8 - Fetch M3U8 - Server fetches the M3U8 file from the provided URL
- Parse Content - Identifies M3U8 playlists vs. media files
- Rewrite URLs - Converts all URLs (relative and absolute) to go through the proxy
- Set CORS Headers - Adds CORS headers to the response
- Return Content - Returns the modified M3U8 or the raw media file
Original M3U8:
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=2332661
/playlist/index.m3u8
#EXTINF:5.005,
https://cdn.example.com/segment-1.ts
Rewritten by proxy:
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=2332661
http://localhost:8080/proxy?url=https://example.com/playlist/index.m3u8
#EXTINF:5.005,
http://localhost:8080/proxy?url=https://cdn.example.com/segment-1.ts
PORT- Server port (default: 8080)
PORT=3000 npm start- Bypass CORS - Stream content blocked by CORS policies
- Unified Domain - Consolidate requests from multiple CDN/servers through one endpoint
- URL Rewriting - Modify streaming URLs for compatibility with players
- Security - Hide actual streaming server URLs from clients
Returns API information and usage examples.
Returns server health status.
Main proxy endpoint. Fetches and proxies M3U8 or media files.
- 400 - Missing or invalid URL parameter
- 404 - Resource not found on the remote server
- 408 - Request timeout
- 500 - Server error
Error responses are returned as JSON:
{
"error": "Error description",
"message": "Detailed error message"
}- No caching (each request fetches fresh content)
- No authentication forwarding (credentials must be in the URL)
- Timeouts set to 10 seconds
- No bandwidth throttling
- Be cautious with URLs that contain authentication tokens
- The proxy will expose the original URLs in the request logs
- Consider implementing IP whitelisting or rate limiting in production
MIT