Skip to content

Commit

Permalink
Fix invalid headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Eltik committed Mar 11, 2023
1 parent 2733ce1 commit 1c9f5a9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
20 changes: 18 additions & 2 deletions built/server.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion built/server.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,26 @@ const server = http.createServer();
server.on("request", async (req, res) => {
const uri = new URL(req.url, "http://localhost:3000");
if (uri.pathname === "/m3u8_proxy") {
const headers = JSON.parse(uri.searchParams.get("headers"));
let headers = {};
try {
headers = JSON.parse(uri.searchParams.get("headers"));
} catch (e) {
res.writeHead(500);
res.end(e.message);
return;
}
const url = uri.searchParams.get("url");
const proxy = new M3U8Proxy(url);
await proxy.proxy(headers, res);
} else if (uri.pathname === "/ts_proxy") {
const headers = JSON.parse(uri.searchParams.get("headers"));
let headers = {};
try {
headers = JSON.parse(uri.searchParams.get("headers"));
} catch (e) {
res.writeHead(500);
res.end(e.message);
return;
}
const url = uri.searchParams.get("url");
const proxy = new M3U8Proxy(url);
await proxy.proxyTs(headers, req, res);
Expand Down

0 comments on commit 1c9f5a9

Please sign in to comment.