Skip to content

Commit 07fb03e

Browse files
fix: normalize RSC URL path by absorbing leading/trailing slashes
1 parent 9e64f73 commit 07fb03e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

node_package/src/RSCClientRoot.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const createFromFetch = async (fetchPromise: Promise<Response>) => {
2727

2828
const fetchRSC = ({ componentName, rscRenderingUrlPath }: RSCClientRootProps) => {
2929
if (!renderCache[componentName]) {
30-
renderCache[componentName] = createFromFetch(fetch(`${rscRenderingUrlPath}/${componentName}`)) as Promise<React.ReactNode>;
30+
const strippedUrlPath = rscRenderingUrlPath.replace(/^\/|\/$/g, '');
31+
renderCache[componentName] = createFromFetch(fetch(`/${strippedUrlPath}/${componentName}`)) as Promise<React.ReactNode>;
3132
}
3233
return renderCache[componentName];
3334
}

0 commit comments

Comments
 (0)