File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { DOMParser } from "https://deno.land/x/deno_dom@v0.1.56/deno-dom-wasm.ts
33export default async ( request , context ) => {
44 const url = new URL ( request . url ) ;
55 const originalOrigin = "https://docs.redpanda.com" ;
6+ const currentOrigin = url . origin ;
67
78 // Redirects from old API paths to new ones
89 const redirects = {
@@ -82,10 +83,13 @@ export default async (request, context) => {
8283 fetchWidget ( `${ originalOrigin } /assets/widgets/footer.html` , "footer" ) ,
8384 ] ) ;
8485
85- const document = new DOMParser ( ) . parseFromString ( originalHtml , "text/html" ) ;
86+ // Rewrite absolute docs.redpanda.com URLs to use current origin to avoid CORS and history API issues
87+ const rewrittenHtml = originalHtml . replace ( / h t t p s : \/ \/ d o c s \. r e d p a n d a \. c o m / g, currentOrigin ) ;
88+
89+ const document = new DOMParser ( ) . parseFromString ( rewrittenHtml , "text/html" ) ;
8690 if ( ! document ) {
8791 console . error ( "❌ Failed to parse Bump.sh HTML." ) ;
88- return new Response ( originalHtml , {
92+ return new Response ( rewrittenHtml , {
8993 status : 200 ,
9094 headers : { "content-type" : "text/html; charset=utf-8" } ,
9195 } ) ;
You can’t perform that action at this time.
0 commit comments