Skip to content

Commit

Permalink
Fixed server.ts again
Browse files Browse the repository at this point in the history
  • Loading branch information
Eltik committed Jul 2, 2023
1 parent 0fd95f0 commit e80dbb1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions dist/libraries/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ async function proxyM3U8(url, headers, res) {
newLines.push(`${web_server_url + "/m3u8-proxy?url=" + encodeURIComponent(uri.href) + "&headers=" + encodeURIComponent(JSON.stringify(headers))}`);
}
}
["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("Access-Control-Allow-Origin", "*");
Expand Down Expand Up @@ -617,6 +618,7 @@ async function proxyTs(url, headers, req, res) {
if (forceHTTPS) {
const proxy = node_https_1.default.request(options, (r) => {
res.writeHead(r.statusCode ?? 200, r.headers);
["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));
r.pipe(res, {
end: true,
});
Expand All @@ -628,6 +630,7 @@ async function proxyTs(url, headers, req, res) {
else {
const proxy = node_http_1.default.request(options, (r) => {
res.writeHead(r.statusCode ?? 200, r.headers);
["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));
r.pipe(res, {
end: true,
});
Expand Down
Loading

0 comments on commit e80dbb1

Please sign in to comment.