Skip to content

Commit eb72a6f

Browse files
committed
Add back-compat for manifest parameter
1 parent 6a92c78 commit eb72a6f

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

.changeset/rare-jobs-remember.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-router": patch
3+
---
4+
5+
[REMOVE] Follow up to https://github.com/remix-run/react-router/pull/14321 to avoid issues with rolling deployments

packages/react-router/lib/server-runtime/server.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -354,19 +354,15 @@ async function handleManifestRequest(
354354

355355
let patches: Record<string, EntryRoute> = {};
356356

357-
if (url.searchParams.has("paths")) {
357+
// Support both the old (`p`) and new formats (`paths`) to avoid issues during
358+
// rolling deployments where an old client hits a new server
359+
if (url.searchParams.has("p") || url.searchParams.has("paths")) {
358360
let paths = new Set<string>();
359361

360-
// In addition to responding with the patches for the requested paths, we
361-
// need to include patches for each partial path so that we pick up any
362-
// pathless/index routes below ancestor segments. So if we
363-
// get a request for `/parent/child`, we need to look for a match on `/parent`
364-
// so that if a `parent._index` route exists we return it so it's available
365-
// for client side matching if the user routes back up to `/parent`.
366-
// This is the same thing we do on initial load in <Scripts> via
367-
// `getPartialManifest()`
368-
let pathParam = url.searchParams.get("paths") || "";
369-
let requestedPaths = pathParam.split(",").filter(Boolean);
362+
let requestedPaths = url.searchParams.has("paths")
363+
? (url.searchParams.get("paths") || "").split(",").filter(Boolean)
364+
: url.searchParams.getAll("p");
365+
370366
requestedPaths.forEach((path) => {
371367
if (!path.startsWith("/")) {
372368
path = `/${path}`;
@@ -378,6 +374,14 @@ async function handleManifestRequest(
378374
});
379375
});
380376

377+
// In addition to responding with the patches for the requested paths, we
378+
// need to include patches for each partial path so that we pick up any
379+
// pathless/index routes below ancestor segments. So if we
380+
// get a request for `/parent/child`, we need to look for a match on `/parent`
381+
// so that if a `parent._index` route exists we return it so it's available
382+
// for client side matching if the user routes back up to `/parent`.
383+
// This is the same thing we do on initial load in <Scripts> via
384+
// `getPartialManifest()`
381385
for (let path of paths) {
382386
let matches = matchServerRoutes(routes, path, build.basename);
383387
if (matches) {

0 commit comments

Comments
 (0)