This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 31a3014696 NIFI-13695 Fixed Redirect Handling for Custom UI Extensions
31a3014696 is described below

commit 31a301469612807413c1322edb4d11b2f97ff869
Author: Matt Gilman <[email protected]>
AuthorDate: Fri Aug 30 10:20:23 2024 -0400

    NIFI-13695 Fixed Redirect Handling for Custom UI Extensions
    
    Appending a trailing slash when opening a custom UI and in the query string 
to fragment filter to avoid a Jetty-based redirect that could lead to losing 
the proxy path.
    
    This closes #9222
    
    Signed-off-by: David Handermann <[email protected]>
---
 .../apache/nifi/web/servlet/filter/QueryStringToFragmentFilter.java    | 3 ++-
 .../apps/nifi/src/app/ui/common/advanced-ui/advanced-ui.component.ts   | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git 
a/nifi-commons/nifi-web-servlet-shared/src/main/java/org/apache/nifi/web/servlet/filter/QueryStringToFragmentFilter.java
 
b/nifi-commons/nifi-web-servlet-shared/src/main/java/org/apache/nifi/web/servlet/filter/QueryStringToFragmentFilter.java
index e6f9a967c8..4113aabbda 100644
--- 
a/nifi-commons/nifi-web-servlet-shared/src/main/java/org/apache/nifi/web/servlet/filter/QueryStringToFragmentFilter.java
+++ 
b/nifi-commons/nifi-web-servlet-shared/src/main/java/org/apache/nifi/web/servlet/filter/QueryStringToFragmentFilter.java
@@ -40,7 +40,8 @@ public class QueryStringToFragmentFilter implements Filter {
             // Some NiFi front ends use hash based routing, so they don't need 
to know the baseHref. With hash based
             // routing query parameters are implemented within the URL 
fragment. Because of this any query parameters on the
             // original URL are not considered. This filter captures those and 
adds them to the fragment.
-            final RequestUriBuilder requestUriBuilder = 
RequestUriBuilder.fromHttpServletRequest(httpServletRequest).path(httpServletRequest.getContextPath()).fragment("/?"
 + queryString);
+            final String contextPath = httpServletRequest.getContextPath() + 
"/";
+            final RequestUriBuilder requestUriBuilder = 
RequestUriBuilder.fromHttpServletRequest(httpServletRequest).path(contextPath).fragment("/?"
 + queryString);
             final URI redirectUri = requestUriBuilder.build();
 
             final HttpServletResponse httpServletResponse = 
(HttpServletResponse) response;
diff --git 
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/ui/common/advanced-ui/advanced-ui.component.ts
 
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/ui/common/advanced-ui/advanced-ui.component.ts
index bb7258edac..6481897d12 100644
--- 
a/nifi-frontend/src/main/frontend/apps/nifi/src/app/ui/common/advanced-ui/advanced-ui.component.ts
+++ 
b/nifi-frontend/src/main/frontend/apps/nifi/src/app/ui/common/advanced-ui/advanced-ui.component.ts
@@ -81,7 +81,7 @@ export class AdvancedUi {
             .set('editable', params.editable)
             .set('disconnectedNodeAcknowledged', 
params.disconnectedNodeAcknowledged)
             .toString();
-        const url = `${params.url}?${queryParams}`;
+        const url = `${params.url}/?${queryParams}`;
 
         const sanitizedUrl = this.domSanitizer.sanitize(SecurityContext.URL, 
url);
 

Reply via email to