mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 14:03:06 +00:00
Added rendering namespace when client side
This commit is contained in:
23
server.ts
23
server.ts
@@ -303,13 +303,24 @@ function serverSideRender(req, res, sendToUser: boolean = true) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Read file once at startup
|
||||||
* Send back response to user to trigger direct client-side rendering (CSR)
|
const indexHtmlContent = readFileSync(indexHtml, 'utf8');
|
||||||
* @param req current request
|
|
||||||
* @param res current response
|
|
||||||
*/
|
|
||||||
function clientSideRender(req, res) {
|
function clientSideRender(req, res) {
|
||||||
res.sendFile(indexHtml);
|
const namespace = environment.ui.nameSpace || '/';
|
||||||
|
let html = indexHtmlContent;
|
||||||
|
// Replace base href dynamically
|
||||||
|
html = html.replace(
|
||||||
|
/<base href="[^"]*">/,
|
||||||
|
`<base href="${namespace.endsWith('/') ? namespace : namespace + '/'}">`
|
||||||
|
);
|
||||||
|
|
||||||
|
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user