@mariozechner/pi-proxy 0.7.28 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -14
- package/dist/cli.js.map +0 -1
- package/dist/cors-proxy.d.ts +0 -4
- package/dist/cors-proxy.d.ts.map +0 -1
- package/dist/cors-proxy.js +0 -63
- package/dist/cors-proxy.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
package/package.json
CHANGED
package/dist/cli.d.ts
DELETED
package/dist/cli.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { spawn } from "node:child_process";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
-
const port = process.argv[2] || "3001";
|
|
7
|
-
// Run the CORS proxy
|
|
8
|
-
const child = spawn("node", [path.join(__dirname, "cors-proxy.js"), port], {
|
|
9
|
-
stdio: "inherit",
|
|
10
|
-
});
|
|
11
|
-
child.on("exit", (code) => {
|
|
12
|
-
process.exit(code || 0);
|
|
13
|
-
});
|
|
14
|
-
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;AAEvC,qBAAqB;AACrB,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC,EAAE,IAAI,CAAC,EAAE;IAC1E,KAAK,EAAE,SAAS;CAChB,CAAC,CAAC;AAEH,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;IACzB,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { spawn } from \"node:child_process\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst port = process.argv[2] || \"3001\";\n\n// Run the CORS proxy\nconst child = spawn(\"node\", [path.join(__dirname, \"cors-proxy.js\"), port], {\n\tstdio: \"inherit\",\n});\n\nchild.on(\"exit\", (code) => {\n\tprocess.exit(code || 0);\n});\n"]}
|
package/dist/cors-proxy.d.ts
DELETED
package/dist/cors-proxy.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cors-proxy.d.ts","sourceRoot":"","sources":["../src/cors-proxy.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,wBAAgB,eAAe,+EAqD9B"}
|
package/dist/cors-proxy.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { serve } from "@hono/node-server";
|
|
3
|
-
import { Hono } from "hono";
|
|
4
|
-
import { cors } from "hono/cors";
|
|
5
|
-
export function createCorsProxy() {
|
|
6
|
-
const app = new Hono();
|
|
7
|
-
// Enable CORS for all origins
|
|
8
|
-
app.use("*", cors());
|
|
9
|
-
// Proxy all requests
|
|
10
|
-
app.all("*", async (c) => {
|
|
11
|
-
const url = new URL(c.req.url);
|
|
12
|
-
const targetUrl = url.searchParams.get("url");
|
|
13
|
-
if (!targetUrl) {
|
|
14
|
-
return c.json({ error: "Missing 'url' query parameter" }, 400);
|
|
15
|
-
}
|
|
16
|
-
try {
|
|
17
|
-
// Forward the request
|
|
18
|
-
const headers = new Headers();
|
|
19
|
-
c.req.raw.headers.forEach((value, key) => {
|
|
20
|
-
// Skip host and origin headers
|
|
21
|
-
if (key.toLowerCase() !== "host" && key.toLowerCase() !== "origin") {
|
|
22
|
-
headers.set(key, value);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
const response = await fetch(targetUrl, {
|
|
26
|
-
method: c.req.method,
|
|
27
|
-
headers,
|
|
28
|
-
body: c.req.method !== "GET" && c.req.method !== "HEAD" ? await c.req.raw.clone().arrayBuffer() : undefined,
|
|
29
|
-
});
|
|
30
|
-
// Forward response headers
|
|
31
|
-
const responseHeaders = new Headers();
|
|
32
|
-
response.headers.forEach((value, key) => {
|
|
33
|
-
// Skip CORS headers (we handle them)
|
|
34
|
-
if (!key.toLowerCase().startsWith("access-control-")) {
|
|
35
|
-
responseHeaders.set(key, value);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
// Return proxied response
|
|
39
|
-
return new Response(response.body, {
|
|
40
|
-
status: response.status,
|
|
41
|
-
statusText: response.statusText,
|
|
42
|
-
headers: responseHeaders,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
console.error("Proxy error:", error);
|
|
47
|
-
return c.json({ error: error instanceof Error ? error.message : "Proxy request failed" }, 502);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
return app;
|
|
51
|
-
}
|
|
52
|
-
// CLI entry point
|
|
53
|
-
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
54
|
-
const app = createCorsProxy();
|
|
55
|
-
const port = Number.parseInt(process.argv[2] || "3001", 10);
|
|
56
|
-
console.log(`🔌 CORS proxy running on http://localhost:${port}`);
|
|
57
|
-
console.log(`Usage: http://localhost:${port}?url=<target-url>`);
|
|
58
|
-
serve({
|
|
59
|
-
fetch: app.fetch,
|
|
60
|
-
port,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=cors-proxy.js.map
|
package/dist/cors-proxy.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cors-proxy.js","sourceRoot":"","sources":["../src/cors-proxy.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,UAAU,eAAe;IAC9B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IAEvB,8BAA8B;IAC9B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IAErB,qBAAqB;IACrB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QACxB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,SAAS,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAE9C,IAAI,CAAC,SAAS,EAAE,CAAC;YAChB,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,+BAA+B,EAAE,EAAE,GAAG,CAAC,CAAC;QAChE,CAAC;QAED,IAAI,CAAC;YACJ,sBAAsB;YACt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O,EAAE,eAAe;aACxB,CAAC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;YACrC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,sBAAsB,EAAE,EAAE,GAAG,CAAC,CAAC;QAChG,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,kBAAkB;AAClB,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACrD,MAAM,GAAG,GAAG,eAAe,EAAE,CAAC;IAC9B,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,EAAE,CAAC,CAAC;IAE5D,OAAO,CAAC,GAAG,CAAC,6CAA6C,IAAI,EAAE,CAAC,CAAC;IACjE,OAAO,CAAC,GAAG,CAAC,2BAA2B,IAAI,mBAAmB,CAAC,CAAC;IAEhE,KAAK,CAAC;QACL,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,IAAI;KACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { serve } from \"@hono/node-server\";\nimport { Hono } from \"hono\";\nimport { cors } from \"hono/cors\";\n\nexport function createCorsProxy() {\n\tconst app = new Hono();\n\n\t// Enable CORS for all origins\n\tapp.use(\"*\", cors());\n\n\t// Proxy all requests\n\tapp.all(\"*\", async (c) => {\n\t\tconst url = new URL(c.req.url);\n\t\tconst targetUrl = url.searchParams.get(\"url\");\n\n\t\tif (!targetUrl) {\n\t\t\treturn c.json({ error: \"Missing 'url' query parameter\" }, 400);\n\t\t}\n\n\t\ttry {\n\t\t\t// Forward the request\n\t\t\tconst headers = new Headers();\n\t\t\tc.req.raw.headers.forEach((value, key) => {\n\t\t\t\t// Skip host and origin headers\n\t\t\t\tif (key.toLowerCase() !== \"host\" && key.toLowerCase() !== \"origin\") {\n\t\t\t\t\theaders.set(key, value);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst response = await fetch(targetUrl, {\n\t\t\t\tmethod: c.req.method,\n\t\t\t\theaders,\n\t\t\t\tbody: c.req.method !== \"GET\" && c.req.method !== \"HEAD\" ? await c.req.raw.clone().arrayBuffer() : undefined,\n\t\t\t});\n\n\t\t\t// Forward response headers\n\t\t\tconst responseHeaders = new Headers();\n\t\t\tresponse.headers.forEach((value, key) => {\n\t\t\t\t// Skip CORS headers (we handle them)\n\t\t\t\tif (!key.toLowerCase().startsWith(\"access-control-\")) {\n\t\t\t\t\tresponseHeaders.set(key, value);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// Return proxied response\n\t\t\treturn new Response(response.body, {\n\t\t\t\tstatus: response.status,\n\t\t\t\tstatusText: response.statusText,\n\t\t\t\theaders: responseHeaders,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tconsole.error(\"Proxy error:\", error);\n\t\t\treturn c.json({ error: error instanceof Error ? error.message : \"Proxy request failed\" }, 502);\n\t\t}\n\t});\n\n\treturn app;\n}\n\n// CLI entry point\nif (import.meta.url === `file://${process.argv[1]}`) {\n\tconst app = createCorsProxy();\n\tconst port = Number.parseInt(process.argv[2] || \"3001\", 10);\n\n\tconsole.log(`🔌 CORS proxy running on http://localhost:${port}`);\n\tconsole.log(`Usage: http://localhost:${port}?url=<target-url>`);\n\n\tserve({\n\t\tfetch: app.fetch,\n\t\tport,\n\t});\n}\n"]}
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
DELETED
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["export { createCorsProxy } from \"./cors-proxy.js\";\n"]}
|