From 32e939c22a5d3f439f7a55e594be0525be8ae4b6 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 15 Jun 2026 15:08:59 +0000 Subject: [PATCH] [star-rating] Load feedback widget assets via document-relative paths The feedback rating popup is rendered into an iframe by the web SDK and is commonly served behind a reverse proxy mounted on an arbitrary, app-specific sub-folder (e.g. /hr/analytics/). The Countly server has no knowledge of that sub-folder, so emitting asset URLs from the global countlyConfig.path (empty on a root install) produced /star-rating/..., /javascripts/... etc. which resolve against the app origin and 404 behind the proxy. Emit document-relative paths instead, computed per route so they resolve under whatever sub-folder the widget was loaded from: /feedback/rating (two segments) -> ../ /feedback (legacy, one segment) -> '' This also keeps working for plain root installs and installs with a configured countlyConfig.path. Runtime API/logo URLs are unchanged (they already build on the SDK-provided server url). https://claude.ai/code/session_0191WRvHa7axoNxMLPu7xQhk --- CHANGELOG.md | 4 ++ plugins/star-rating/frontend/app.js | 12 ++++- .../public/templates/feedback-popup.html | 48 +++++++++---------- 3 files changed, 39 insertions(+), 25 deletions(-) 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 @@ > - - + +