Skip to content

Commit 0041f15

Browse files
committed
fix(singlefetch): handle root path with basename
1 parent dd28f63 commit 0041f15

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

contributors.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@
662662
- tascord
663663
- TheRealAstoo
664664
- therealflyingcoder
665+
- ThisIsAreku
665666
- thomasheyenbrock
666667
- thomasrettig
667668
- thomasverleye

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)