@inflector/aura 0.4.3 → 0.4.4
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.js +10 -1
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -626,6 +626,7 @@ async function start() {
|
|
|
626
626
|
const targetUrl = `${upstreamUrl}${url.pathname}${url.search}`;
|
|
627
627
|
const headers = new Headers(req.headers);
|
|
628
628
|
headers.delete("host");
|
|
629
|
+
headers.delete("accept-encoding");
|
|
629
630
|
headers.set("x-forwarded-host", req.headers.get("x-forwarded-host") ?? req.headers.get("host"));
|
|
630
631
|
const forwardedProto = req.headers.get("x-forwarded-proto") ??
|
|
631
632
|
req.headers.get("x-forwarded-scheme") ??
|
|
@@ -635,13 +636,21 @@ async function start() {
|
|
|
635
636
|
if (AURA_KEY)
|
|
636
637
|
headers.set("Authorization", `Bearer ${AURA_KEY}`);
|
|
637
638
|
try {
|
|
638
|
-
|
|
639
|
+
const proxiedResp = await fetch(targetUrl, {
|
|
639
640
|
method: req.method,
|
|
640
641
|
headers,
|
|
641
642
|
body: req.method === "GET" || req.method === "HEAD"
|
|
642
643
|
? undefined
|
|
643
644
|
: req.body,
|
|
644
645
|
});
|
|
646
|
+
const proxyHeaders = new Headers(proxiedResp.headers);
|
|
647
|
+
proxyHeaders.delete("content-encoding");
|
|
648
|
+
proxyHeaders.delete("content-length");
|
|
649
|
+
return new Response(proxiedResp.body, {
|
|
650
|
+
status: proxiedResp.status,
|
|
651
|
+
statusText: proxiedResp.statusText,
|
|
652
|
+
headers: proxyHeaders,
|
|
653
|
+
});
|
|
645
654
|
}
|
|
646
655
|
catch {
|
|
647
656
|
return new Response(JSON.stringify({ error: "Upstream Proxy Failed" }), { status: 502, headers: { "Content-Type": "application/json" } });
|