This is an automated email from the ASF dual-hosted git repository. ahuber pushed a commit to branch 3973-reverse.proxy.fix in repository https://gitbox.apache.org/repos/asf/causeway.git
commit 429dfa250d53075dcdab30424b3505fd10e37e51 Author: andi-huber <[email protected]> AuthorDate: Thu Mar 12 14:19:33 2026 +0100 CAUSEWAY-3976: [v2] backport, enhances client side javascript code, that helps with handling redirects - auto correct URL origin --- adoc/changelog.adoc | 1 + .../causeway/viewer/wicket/ui/exec/Mediator.java | 24 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/adoc/changelog.adoc b/adoc/changelog.adoc index ae0c518e110..d3ea1be452a 100644 --- a/adoc/changelog.adoc +++ b/adoc/changelog.adoc @@ -2,6 +2,7 @@ 🐞 Bug Fixes +- [Wicket Viewer] Table Row Actions Redirect might fail if behind Reverse Proxy https://issues.apache.org/jira/browse/CAUSEWAY-3976[CAUSEWAY-3976] - [Commons] Internal OneShot Util may deadlock https://issues.apache.org/jira/browse/CAUSEWAY-3972[CAUSEWAY-3972] (potentially preventing App from startup) diff --git a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/exec/Mediator.java b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/exec/Mediator.java index 94d4d24fe30..499ef3321e7 100644 --- a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/exec/Mediator.java +++ b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/exec/Mediator.java @@ -193,11 +193,31 @@ private static String expanded(String urlStr) { } private static String javascriptFor_newWindow(final CharSequence url) { - return "function(){Wicket.Event.publish(Causeway.Topic.OPEN_IN_NEW_TAB, '" + url + "');}"; + return String.format("function(){\n" + + " const url = '%s';\n" + + " const requiredOrigin = window.location.origin;\n" + + " const replacedUrl = url.startsWith(requiredOrigin)\n" + + " ? url\n" + + " : (() => {\n" + + " const urlObj = new URL(url);\n" + + " return requiredOrigin + urlObj.pathname + urlObj.search + urlObj.hash;\n" + + " })();\n" + + " Wicket.Event.publish(Causeway.Topic.OPEN_IN_NEW_TAB, replacedUrl);\n" + + "}", url); } private static String javascriptFor_sameWindow(final CharSequence url) { - return "\"window.location.href='" + url + "'\""; + return String.format("function(){\n" + + " const url = '%s';\n" + + " const requiredOrigin = window.location.origin;\n" + + " const replacedUrl = url.startsWith(requiredOrigin)\n" + + " ? url\n" + + " : (() => {\n" + + " const urlObj = new URL(url);\n" + + " return requiredOrigin + urlObj.pathname + urlObj.search + urlObj.hash;\n" + + " })();\n" + + " window.location.href=replacedUrl;\n" + + "}", url); } private static void scheduleJs(final AjaxRequestTarget target, final String js, final int millis) {
