Openstatus www.openstatus.dev

fix: url

+11 -11
+11 -11
apps/status-page/src/middleware.ts
··· 63 63 64 64 // custom domain redirect 65 65 if (_page.customDomain && host !== `${_page.slug}.stpg.dev`) { 66 - const newURL = new URL(`https://${_page.customDomain}`); 67 - const newPathname = pathname.replace(`/${_page.customDomain}`, ""); 68 - newURL.pathname = `/protected?redirect=${encodeURIComponent( 69 - newPathname, 70 - )}`; 71 - console.log("redirect to /protected", newURL.toString()); 72 - return NextResponse.redirect(newURL); 66 + const redirect = pathname.replace(`/${_page.customDomain}`, ""); 67 + const url = new URL( 68 + `https://${ 69 + _page.customDomain 70 + }/protected?redirect=${encodeURIComponent(redirect)}`, 71 + ); 72 + console.log("redirect to /protected", url.toString()); 73 + return NextResponse.redirect(url); 73 74 } 74 75 75 76 const url = new URL( ··· 84 85 85 86 // custom domain redirect 86 87 if (_page.customDomain && host !== `${_page.slug}.stpg.dev`) { 87 - const newURL = new URL(`https://${_page.customDomain}`); 88 - newURL.pathname = redirect ?? "/"; 89 - console.log("redirect to /", newURL.toString()); 90 - return NextResponse.redirect(newURL); 88 + const url = new URL(`https://${_page.customDomain}${redirect ?? "/"}`); 89 + console.log("redirect to /", url.toString()); 90 + return NextResponse.redirect(url); 91 91 } 92 92 93 93 return NextResponse.redirect(