File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/filter Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,15 @@ private boolean redirectLegacyAppPaths(
99
99
boolean matchesPattern = m .find ();
100
100
boolean isIndexPath = path .endsWith ("/" ) || path .endsWith ("/index.html" );
101
101
boolean hasRedirectFalse = queryString != null && queryString .contains ("redirect=false" );
102
- if (matchesPattern && isIndexPath && !hasRedirectFalse ) {
102
+
103
+ // Referer header is set by the browser when the request is made from a service worker
104
+ // TODO: Enforce that apps must use the path 'service-worker.js' for service worker
105
+ // registration perhaps by checking the 'Service-Worker' request header, see
106
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Service-Worker
107
+ String referer = request .getHeader ("Referer" );
108
+ boolean sentFromServiceWorker = referer != null && referer .endsWith ("service-worker.js" );
109
+
110
+ if (matchesPattern && isIndexPath && !hasRedirectFalse && !sentFromServiceWorker ) {
103
111
String appName = m .group (1 );
104
112
response .sendRedirect (request .getContextPath () + GLOBAL_SHELL_PATH_PREFIX + appName );
105
113
log .debug ("Redirecting to global shell" );
You can’t perform that action at this time.
0 commit comments