From 791b022cedc55ed100413b33bfd664a6cdb3fd9d 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 89428f9bd3..8b80b306cf 100644 --- a/server.ts +++ b/server.ts @@ -309,13 +309,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 6ae5f98c7f52f6c39219c52d6886236bd65ebc01 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 8b80b306cf..2f66c78d86 100644 --- a/server.ts +++ b/server.ts @@ -322,7 +322,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); }