Skip to content

Commit

Permalink
Lift loader base url
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Mar 19, 2024
1 parent 2adc5f0 commit be61761
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/remix-react/single-fetch.tsx
Expand Up @@ -158,10 +158,11 @@ function singleFetchLoaderStrategy(
matches.map(async (m) =>
m.resolve(async (handler): Promise<HandlerResult> => {
let result: unknown;
let url = stripIndexParam(singleFetchUrl(request.url));

// When a route has a client loader, it calls it's singular server loader
if (manifest.routes[m.route.id].hasClientLoader) {
result = await handler(async () => {
let url = stripIndexParam(singleFetchUrl(request.url));
url.searchParams.set("_routes", m.route.id);
let { data } = await fetchAndDecode(url);
return unwrapSingleFetchResults(
Expand All @@ -173,12 +174,12 @@ function singleFetchLoaderStrategy(
result = await handler(async () => {
// Otherwise we let multiple routes hook onto the same promise
if (!singleFetchPromise) {
let url = addRevalidationParam(
url = addRevalidationParam(
manifest,
routeModules,
matches.map((m) => m.route),
matches.filter((m) => m.shouldLoad).map((m) => m.route),
stripIndexParam(singleFetchUrl(request.url))
url
);
singleFetchPromise = fetchAndDecode(url).then(
({ data }) => data as SingleFetchResults
Expand Down

0 comments on commit be61761

Please sign in to comment.