Skip to content

Commit e5b4694

Browse files
committed
fix(rsc): ensure trailing slash of BASE_URL
1 parent 1b4e0f0 commit e5b4694

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/plugin-rsc/src/browser.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ function initialize(): void {
1010
load: async (id) => {
1111
if (!import.meta.env.__vite_rsc_build__) {
1212
// @ts-ignore
13-
return __vite_rsc_raw_import__(import.meta.env.BASE_URL + id.slice(1))
13+
return __vite_rsc_raw_import__(
14+
withTrailingSlash(import.meta.env.BASE_URL) + id.slice(1),
15+
)
1416
} else {
1517
const import_ = clientReferences.default[id]
1618
if (!import_) {
@@ -21,3 +23,11 @@ function initialize(): void {
2123
},
2224
})
2325
}
26+
27+
// https://github.com/vitejs/vite/blob/27a192fc95036dbdb6e615a4201b858eb64aa075/packages/vite/src/shared/utils.ts#L48-L53
28+
function withTrailingSlash(path: string): string {
29+
if (path[path.length - 1] !== '/') {
30+
return `${path}/`
31+
}
32+
return path
33+
}

0 commit comments

Comments
 (0)