Skip to content

Commit

Permalink
Force set content type on ts proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Eltik committed Jul 2, 2023
1 parent 9231dba commit 5ab87fe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dist/libraries/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ async function proxyM3U8(url, headers, res) {
["Access-Control-Allow-Origin", "Access-Control-Allow-Methods", "Access-Control-Allow-Headers", "Access-Control-Max-Age", "Access-Control-Allow-Credentials", "Access-Control-Expose-Headers", "Access-Control-Request-Method", "Access-Control-Request-Headers", "Origin", "Vary", "Referer", "Server", "x-cache", "via", "x-amz-cf-pop", "x-amz-cf-id"].map((header) => res.removeHeader(header));
// You need these headers so that the client recognizes the response as an m3u8.
res.setHeader("Content-Type", "application/vnd.apple.mpegurl");
res.setHeader("Content-Type", "video/mp2t");
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Headers", "*");
res.setHeader("Access-Control-Allow-Methods", "*");
Expand Down Expand Up @@ -579,7 +578,6 @@ async function proxyM3U8(url, headers, res) {
["Access-Control-Allow-Origin", "Access-Control-Allow-Methods", "Access-Control-Allow-Headers", "Access-Control-Max-Age", "Access-Control-Allow-Credentials", "Access-Control-Expose-Headers", "Access-Control-Request-Method", "Access-Control-Request-Headers", "Origin", "Vary", "Referer", "Server", "x-cache", "via", "x-amz-cf-pop", "x-amz-cf-id"].map((header) => res.removeHeader(header));
// You need these headers so that the client recognizes the response as an m3u8.
res.setHeader("Content-Type", "application/vnd.apple.mpegurl");
res.setHeader("Content-Type", "video/mp2t");
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Headers", "*");
res.setHeader("Access-Control-Allow-Methods", "*");
Expand Down Expand Up @@ -619,6 +617,7 @@ async function proxyTs(url, headers, req, res) {
try {
if (forceHTTPS) {
const proxy = node_https_1.default.request(options, (r) => {
r.headers["content-type"] = "video/mp2t";
res.writeHead(r.statusCode ?? 200, r.headers);
r.pipe(res, {
end: true,
Expand All @@ -630,6 +629,7 @@ async function proxyTs(url, headers, req, res) {
}
else {
const proxy = node_http_1.default.request(options, (r) => {
r.headers["content-type"] = "video/mp2t";
res.writeHead(r.statusCode ?? 200, r.headers);
r.pipe(res, {
end: true,
Expand Down
Loading

0 comments on commit 5ab87fe

Please sign in to comment.