From 7bc173cb89b4049f4e18ae459eb06bc90970bbcd Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Fri, 8 Aug 2025 16:30:21 +0200 Subject: [PATCH 1/2] Added rendering namespace when client side (cherry picked from commit 75c9112023575246dfce14a1f3559c7105236ac6) --- server.ts | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/server.ts b/server.ts index 0ca6c59939b..003dea33483 100644 --- a/server.ts +++ b/server.ts @@ -310,13 +310,24 @@ function serverSideRender(req, res, next, sendToUser: boolean = true) { }); } -/** - * Send back response to user to trigger direct client-side rendering (CSR) - * @param req current request - * @param res current response - */ +// Read file once at startup +const indexHtmlContent = readFileSync(indexHtml, 'utf8'); + function clientSideRender(req, res) { - res.sendFile(indexHtml); + const namespace = environment.ui.nameSpace || '/'; + let html = indexHtmlContent; + // Replace base href dynamically + html = html.replace( + //, + `` + ); + + // Replace REST URL with UI URL + if (environment.universal.replaceRestUrl && REST_BASE_URL !== environment.rest.baseUrl) { + html = html.replace(new RegExp(REST_BASE_URL, 'g'), environment.rest.baseUrl); + } + + res.send(html); } From ec32cd44ccd25f7f04d026870f7746b7928c8c91 Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Mon, 13 Oct 2025 15:01:44 -0500 Subject: [PATCH 2/2] In DSpace 8+ "environment.universal" is renamed "environment.ssr" --- server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.ts b/server.ts index 003dea33483..1005374088d 100644 --- a/server.ts +++ b/server.ts @@ -323,7 +323,7 @@ function clientSideRender(req, res) { ); // Replace REST URL with UI URL - if (environment.universal.replaceRestUrl && REST_BASE_URL !== environment.rest.baseUrl) { + if (environment.ssr.replaceRestUrl && REST_BASE_URL !== environment.rest.baseUrl) { html = html.replace(new RegExp(REST_BASE_URL, 'g'), environment.rest.baseUrl); }