Commit c8db245 1 parent 0eff92c commit c8db245 Copy full SHA for c8db245
File tree 3 files changed +18
-10
lines changed
3 files changed +18
-10
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @remix-run/react " : patch
3
+ " @remix-run/server-runtime " : patch
4
+ ---
5
+
6
+ Fix reload loops in scenarios where CDNs ignore search params
Original file line number Diff line number Diff line change @@ -181,17 +181,19 @@ export function RemixBrowser(_props: RemixBrowserProps): ReactElement {
181
181
} ,
182
182
} ) ;
183
183
184
- // Hard reload if the URL we tried to load is not the current URL .
185
- // This is usually the result of 2 rapid backwards /forward clicks from an
184
+ // Hard reload if the path we tried to load is not the current path .
185
+ // This is usually the result of 2 rapid back /forward clicks from an
186
186
// external site into a Remix app, where we initially start the load for
187
187
// one URL and while the JS chunks are loading a second forward click moves
188
- // us to a new URL
189
- let initialUrl = window . __remixContext . url ;
190
- let hydratedUrl = window . location . pathname + window . location . search ;
191
- if ( initialUrl !== hydratedUrl ) {
188
+ // us to a new URL. Avoid comparing search params because of CDNs which
189
+ // can be configured to ignore certain params and only pathname is relevant
190
+ // towards determining the route matches.
191
+ let initialPathname = window . __remixContext . url ;
192
+ let hydratedPathname = window . location . pathname ;
193
+ if ( initialPathname !== hydratedPathname ) {
192
194
let errorMsg =
193
- `Initial URL (${ initialUrl } ) does not match URL at time of hydration ` +
194
- `(${ hydratedUrl } ), reloading page...` ;
195
+ `Initial URL (${ initialPathname } ) does not match URL at time of hydration ` +
196
+ `(${ hydratedPathname } ), reloading page...` ;
195
197
console . error ( errorMsg ) ;
196
198
window . location . reload ( ) ;
197
199
}
Original file line number Diff line number Diff line change @@ -289,7 +289,7 @@ async function handleDocumentRequestRR(
289
289
routeModules : createEntryRouteModules ( build . routes ) ,
290
290
staticHandlerContext : context ,
291
291
serverHandoffString : createServerHandoffString ( {
292
- url : context . location . pathname + context . location . search ,
292
+ url : context . location . pathname ,
293
293
state : {
294
294
loaderData : context . loaderData ,
295
295
actionData : context . actionData ,
@@ -335,7 +335,7 @@ async function handleDocumentRequestRR(
335
335
...entryContext ,
336
336
staticHandlerContext : context ,
337
337
serverHandoffString : createServerHandoffString ( {
338
- url : context . location . pathname + context . location . search ,
338
+ url : context . location . pathname ,
339
339
state : {
340
340
loaderData : context . loaderData ,
341
341
actionData : context . actionData ,
You can’t perform that action at this time.
0 commit comments