diff --git a/CHANGELOG.md b/CHANGELOG.md index c05d1507bd9..99bbc023f96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ +## Version 25.03.X +Fixes: +- [star-rating] Serve feedback widget assets via document-relative paths so they resolve when the widget is loaded through a reverse proxy on an app-specific sub-folder + ## Version 25.03.47 Fixes: - [content] Bugfixes for content showing diff --git a/plugins/star-rating/frontend/app.js b/plugins/star-rating/frontend/app.js index 9a3e976f411..cb1c9715a57 100644 --- a/plugins/star-rating/frontend/app.js +++ b/plugins/star-rating/frontend/app.js @@ -36,8 +36,18 @@ var STAR_RATING_EXT_TO_MIME = { countlyPath = `/${countlyPath}`; } + // Static assets in the popup are fetched by the browser relative to the + // iframe's document URL. The widget is frequently served behind a reverse + // proxy mounted on an arbitrary, app-specific sub-folder that the Countly + // server has no knowledge of, so an absolute path (built from countlyPath) + // can never resolve there. We emit document-relative paths instead, which + // resolve under whatever sub-folder the widget was loaded from. + // The popup is reachable at '/feedback/rating' (two segments -> one level + // up) and the legacy '/feedback' (one segment -> same level). + const assetPrefix = /\/feedback\/?$/.test(req.path) ? '' : '../'; + res.removeHeader('X-Frame-Options'); - res.render('../../../plugins/star-rating/frontend/public/templates/feedback-popup', { countlyPath }); + res.render('../../../plugins/star-rating/frontend/public/templates/feedback-popup', { countlyPath, assetPrefix }); } app.get(countlyConfig.path + '/feedback/rating', renderPopup); diff --git a/plugins/star-rating/frontend/public/templates/feedback-popup.html b/plugins/star-rating/frontend/public/templates/feedback-popup.html index 5005901b85f..679fa3b69de 100644 --- a/plugins/star-rating/frontend/public/templates/feedback-popup.html +++ b/plugins/star-rating/frontend/public/templates/feedback-popup.html @@ -2,9 +2,9 @@ Countly Feedback Popup - - - + + + <% if (themeFiles && themeFiles.css) { %> <% for(var i=0, l=themeFiles.css.length; i < l; i++) {%> @@ -14,67 +14,67 @@ @@ -82,7 +82,7 @@
@@ -251,13 +251,13 @@ > - - + +