Add configuration to toggle replace/transfer

This commit is contained in:
Yury Bondarenko
2024-11-20 12:58:38 +01:00
committed by Giuseppe Digilio
parent a3ffda3bf8
commit f9d8e4e0b7
5 changed files with 20 additions and 3 deletions

View File

@@ -272,6 +272,13 @@ function serverSideRender(req, res, sendToUser: boolean = true) {
requestUrl: req.originalUrl,
}, (err, data) => {
if (hasNoValue(err) && hasValue(data)) {
// Replace REST URL with UI URL
if (environment.ui.replaceRestUrl && REST_BASE_URL !== environment.rest.baseUrl) {
const t0 = Date.now();
data = data.replace(new RegExp(REST_BASE_URL, 'g'), environment.rest.baseUrl);
console.log(`Replaced all SSR URLs in HTML in ${Date.now() - t0}ms`); // todo: remove this
}
// save server side rendered page to cache (if any are enabled)
saveToCache(req, data);
if (sendToUser) {