22 lines
641 B
TypeScript
22 lines
641 B
TypeScript
const server = Bun.serve({
|
|
port: 18790,
|
|
hostname: "0.0.0.0",
|
|
async fetch(req) {
|
|
const url = new URL(req.url);
|
|
if (!url.pathname.startsWith("/hooks")) {
|
|
return new Response("Not Found", { status: 404 });
|
|
}
|
|
const target = `http://127.0.0.1:18789${url.pathname}${url.search}`;
|
|
const resp = await fetch(target, {
|
|
method: req.method,
|
|
headers: req.headers,
|
|
body: req.method !== "GET" ? await req.text() : undefined,
|
|
});
|
|
return new Response(resp.body, {
|
|
status: resp.status,
|
|
headers: resp.headers,
|
|
});
|
|
},
|
|
});
|
|
console.log(`Hook proxy listening on 0.0.0.0:${server.port}`);
|