@inflector/aura 0.6.7 → 0.6.8
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/dist/bin.d.ts.map +1 -1
- package/dist/bin.js +13 -2
- package/package.json +1 -1
package/dist/bin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AAmLA,wBAAgB,KAAK,CAAC,MAAM,UAAQ,QAgDnC;AA0aD,wBAAsB,GAAG,
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AAmLA,wBAAgB,KAAK,CAAC,MAAM,UAAQ,QAgDnC;AA0aD,wBAAsB,GAAG,kBAiFxB"}
|
package/dist/bin.js
CHANGED
|
@@ -582,11 +582,17 @@ export async function dev() {
|
|
|
582
582
|
changeOrigin: true,
|
|
583
583
|
secure: false,
|
|
584
584
|
configure(proxy, _options) {
|
|
585
|
-
proxy.on("proxyReq", (proxyReq) => {
|
|
585
|
+
proxy.on("proxyReq", (proxyReq, req, res) => {
|
|
586
586
|
proxyReq.setHeader("Connection", "close");
|
|
587
587
|
if (AURA_KEY) {
|
|
588
588
|
proxyReq.setHeader("Authorization", `Bearer ${AURA_KEY}`);
|
|
589
589
|
}
|
|
590
|
+
// Abort upstream request if client disconnects
|
|
591
|
+
req.on("close", () => {
|
|
592
|
+
if (!res.writableEnded) {
|
|
593
|
+
proxyReq.destroy();
|
|
594
|
+
}
|
|
595
|
+
});
|
|
590
596
|
});
|
|
591
597
|
},
|
|
592
598
|
},
|
|
@@ -643,6 +649,7 @@ async function start() {
|
|
|
643
649
|
body: req.method === "GET" || req.method === "HEAD"
|
|
644
650
|
? undefined
|
|
645
651
|
: req.body,
|
|
652
|
+
signal: req.signal,
|
|
646
653
|
});
|
|
647
654
|
const proxyHeaders = new Headers(proxiedResp.headers);
|
|
648
655
|
proxyHeaders.delete("content-encoding");
|
|
@@ -653,7 +660,11 @@ async function start() {
|
|
|
653
660
|
headers: proxyHeaders,
|
|
654
661
|
});
|
|
655
662
|
}
|
|
656
|
-
catch {
|
|
663
|
+
catch (err) {
|
|
664
|
+
// Client disconnected — no point sending a response
|
|
665
|
+
if (err.name === "AbortError" || req.signal.aborted) {
|
|
666
|
+
return new Response(null, { status: 499 });
|
|
667
|
+
}
|
|
657
668
|
return new Response(JSON.stringify({ error: "Upstream Proxy Failed" }), { status: 502, headers: { "Content-Type": "application/json" } });
|
|
658
669
|
}
|
|
659
670
|
}
|