11import type { PropsWithChildren } from 'react'
22
3- export const normalizeProxiedRscFetch = `
4- (() => {
5- if (window.__tempoNormalizeProxiedRscFetch) return;
6- window.__tempoNormalizeProxiedRscFetch = true;
7- const originalFetch = window.fetch.bind(window);
8- window.fetch = (input, init) => {
9- const url = typeof input === 'string'
10- ? input
11- : input instanceof URL
12- ? input.toString()
13- : input.url;
14- const requestUrl = new URL(url, window.location.href);
15- let rewritten = url;
16- if (requestUrl.pathname.startsWith('/RSC/R/')) {
17- const pathname = requestUrl.pathname
18- .replace(/\\/RSC\\/R\\/developers\\.txt$/, '/RSC/R/_root.txt')
19- .replace(/\\/RSC\\/R\\/developers\\//, '/RSC/R/');
20- rewritten = new URL(
21- pathname + requestUrl.search + requestUrl.hash,
22- window.location.origin,
23- ).toString();
24- }
25-
26- if (rewritten === url) return originalFetch(input, init);
27- if (typeof input === 'string' || input instanceof URL) return originalFetch(rewritten, init);
28-
29- return originalFetch(new Request(rewritten, input), init);
30- };
31- })();
32- `
33-
343export default function Layout (
354 props : PropsWithChildren < {
365 path : string
@@ -46,8 +15,6 @@ export default function Layout(
4615 type = "font/woff2"
4716 crossOrigin = "anonymous"
4817 />
49- { /* biome-ignore lint/security/noDangerouslySetInnerHtml: static bootstrap must run before the RSC client bundle. */ }
50- < script dangerouslySetInnerHTML = { { __html : normalizeProxiedRscFetch } } />
5118 { props . children }
5219 </ >
5320 )
0 commit comments