We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d458dc4 commit d9f19abCopy full SHA for d9f19ab
.changeset/tall-mirrors-glow.md
@@ -0,0 +1,5 @@
1
+---
2
+"@remix-run/react": patch
3
4
+
5
+Fix `window is not defined` error in Single Fetch when server-rendering `<PrefetchPageLinks>`
packages/remix-react/single-fetch.tsx
@@ -381,7 +381,14 @@ function stripIndexParam(url: URL) {
381
export function singleFetchUrl(reqUrl: URL | string) {
382
let url =
383
typeof reqUrl === "string"
384
- ? new URL(reqUrl, window.location.origin)
+ ? new URL(
385
+ reqUrl,
386
+ // This can be called during the SSR flow via PrefetchPageLinksImpl so
387
+ // don't assume window is available
388
+ typeof window === "undefined"
389
+ ? "server://singlefetch/"
390
+ : window.location.origin
391
+ )
392
: reqUrl;
393
394
if (url.pathname === "/") {
0 commit comments