Rename to hkt.sh

This commit is contained in:
mango
2026-03-21 01:10:53 +08:00
parent 76a263d0f9
commit 8f1171fe99
6676 changed files with 1724268 additions and 0 deletions

25
scripts/bookapi-proxy.js Normal file
View File

@@ -0,0 +1,25 @@
const http = require("http");
const https = require("https");
const { URL } = require("url");
const TARGET = "https://tiger.bookapi.cc";
const PORT = 18801;
http.createServer((req, res) => {
const url = new URL(req.url, TARGET);
const headers = { ...req.headers, host: url.host, "user-agent": "curl/8.0" };
// Strip identifying headers
for (const k of Object.keys(headers)) {
if (k.startsWith("x-stainless") || k === "anthropic-dangerous-direct-browser-access" || k === "sec-fetch-mode") {
delete headers[k];
}
}
const proxy = https.request(url.href, { method: req.method, headers }, (pRes) => {
res.writeHead(pRes.statusCode, pRes.headers);
pRes.pipe(res);
});
proxy.on("error", (e) => { res.writeHead(502); res.end(e.message); });
req.pipe(proxy);
}).listen(PORT, "127.0.0.1", () => console.log(`Proxy on 127.0.0.1:${PORT}`));