Skip to content

Commit 7ba6716

Browse files
committed
Simplify proxy to use request origin for all URLs
1 parent 3096f09 commit 7ba6716

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

netlify/edge-functions/proxy-api-docs.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { DOMParser } from "https://deno.land/x/deno_dom@v0.1.56/deno-dom-wasm.ts
22

33
export default async (request, context) => {
44
const url = new URL(request.url);
5-
const originalOrigin = "https://docs.redpanda.com";
6-
const currentOrigin = url.origin;
5+
const originalOrigin = url.origin;
76

87
// Redirects from old API paths to new ones
98
const redirects = {
@@ -83,13 +82,10 @@ export default async (request, context) => {
8382
fetchWidget(`${originalOrigin}/assets/widgets/footer.html`, "footer"),
8483
]);
8584

86-
// Rewrite absolute docs.redpanda.com URLs to use current origin to avoid CORS and history API issues
87-
const rewrittenHtml = originalHtml.replace(/https:\/\/docs\.redpanda\.com/g, currentOrigin);
88-
89-
const document = new DOMParser().parseFromString(rewrittenHtml, "text/html");
85+
const document = new DOMParser().parseFromString(originalHtml, "text/html");
9086
if (!document) {
9187
console.error("❌ Failed to parse Bump.sh HTML.");
92-
return new Response(rewrittenHtml, {
88+
return new Response(originalHtml, {
9389
status: 200,
9490
headers: { "content-type": "text/html; charset=utf-8" },
9591
});

0 commit comments

Comments
 (0)