Skip to content

Commit fa20f51

Browse files
author
Alexandre Boucey
committed
fix(singlefetch): handle root path with basename
1 parent dd28f63 commit fa20f51

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/remix-react/single-fetch.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ export function singleFetchUrl(reqUrl: URL | string) {
393393

394394
if (url.pathname === "/") {
395395
url.pathname = "_root.data";
396+
} else if (url.pathname === window.__remixContext.basename) {
397+
url.pathname = window.__remixContext.basename.concat("_root.data");
396398
} else {
397399
url.pathname = `${url.pathname.replace(/\/$/, "")}.data`;
398400
}

packages/remix-server-runtime/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ export const createRequestHandler: CreateRequestHandlerFunction = (
195195
let handlerUrl = new URL(request.url);
196196
handlerUrl.pathname = handlerUrl.pathname
197197
.replace(/\.data$/, "")
198-
.replace(/^\/_root$/, "/");
198+
.replace(_build.basename ? /\/_root$/ : /^\/_root$/, "/");
199199

200200
let singleFetchMatches = matchServerRoutes(
201201
routes,

0 commit comments

Comments
 (0)