From f3794b3d9eb4a3e9026aa9fd8b728316448f35e4 Mon Sep 17 00:00:00 2001 From: Peter Havekes Date: Fri, 20 Nov 2026 14:28:22 +0100 Subject: [PATCH 1/4] Support serving the client under the /roles/ path prefix When requested via the access dashboard (Host rewritten to the invite vhost, path /roles/...), strip the prefix internally and rewrite root-relative href/src/action links in HTML responses back to /roles/ using mod_substitute. Requires a2enmod substitute. --- client/docker/appconf.conf | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/client/docker/appconf.conf b/client/docker/appconf.conf index 543540e3..e7f7dd3c 100644 --- a/client/docker/appconf.conf +++ b/client/docker/appconf.conf @@ -1,5 +1,10 @@ ServerName accessclient RewriteEngine On +# When served via the access dashboard the app lives under /roles/: +# strip the prefix internally and flag the request so root-relative +# links in the response can be rewritten back to /roles/ +RewriteRule ^/roles/?$ / [E=ROLES_PREFIX:1,L] +RewriteRule ^/roles/(.*)$ /$1 [E=ROLES_PREFIX:1,L] RewriteCond %{REQUEST_URI} !\.(js|css)(\.map)?$ RewriteCond %{REQUEST_URI} !\.svg$ RewriteCond %{REQUEST_URI} !\.png$ @@ -61,3 +66,13 @@ Header set Expires "Sun, 8 Jun 1986 08:06:00 GMT" Header always set X-Frame-Options "DENY" Header always set Referrer-Policy "strict-origin-when-cross-origin" Header always set X-Content-Type-Options "nosniff" + +# Rewrite root-relative links in HTML responses when the app was +# requested under the /roles/ prefix (eg via the access dashboard) + + + Substitute "s|href=\"/|href=\"/roles/|gi" + Substitute "s|src=\"/|src=\"/roles/|gi" + Substitute "s|action=\"/|action=\"/roles/|gi" + + From 0ab2f28e26b9f64955382a8fef9ef1dd7384b755 Mon Sep 17 00:00:00 2001 From: Peter Havekes Date: Fri, 20 Nov 2026 15:03:47 +0100 Subject: [PATCH 2/4] Fix 403 on /roles/ and enable mod_substitute Rewrite the bare /roles/ prefix straight to /index.html instead of / (the appconf fallback to /index.html does not run after [L], and a directory request 403s with Options -Indexes). Enable the substitute module in the image so the response link rewriting actually applies. --- client/docker/Dockerfile | 2 ++ client/docker/appconf.conf | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/client/docker/Dockerfile b/client/docker/Dockerfile index 9924e6e9..0b351e35 100644 --- a/client/docker/Dockerfile +++ b/client/docker/Dockerfile @@ -1,5 +1,7 @@ FROM ghcr.io/openconext/openconext-basecontainers/apache2:latest ADD ./dist/ /var/www/ RUN rm -rf /etc/apache2/sites-enabled/*.conf +# mod_substitute is used to rewrite root-relative links to /roles/ in responses +RUN a2enmod substitute COPY ./docker/appconf.conf /etc/apache2/sites-enabled/ diff --git a/client/docker/appconf.conf b/client/docker/appconf.conf index e7f7dd3c..6dbcc604 100644 --- a/client/docker/appconf.conf +++ b/client/docker/appconf.conf @@ -3,7 +3,7 @@ RewriteEngine On # When served via the access dashboard the app lives under /roles/: # strip the prefix internally and flag the request so root-relative # links in the response can be rewritten back to /roles/ -RewriteRule ^/roles/?$ / [E=ROLES_PREFIX:1,L] +RewriteRule ^/roles/?$ /index.html [E=ROLES_PREFIX:1,L] RewriteRule ^/roles/(.*)$ /$1 [E=ROLES_PREFIX:1,L] RewriteCond %{REQUEST_URI} !\.(js|css)(\.map)?$ RewriteCond %{REQUEST_URI} !\.svg$ From e8530d5b0029fdac21c8b3b3593708ce94c66979 Mon Sep 17 00:00:00 2001 From: Peter Havekes Date: Fri, 20 Nov 2026 15:26:17 +0100 Subject: [PATCH 3/4] Fix Substitute flags: only i is supported, not g --- client/docker/appconf.conf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/docker/appconf.conf b/client/docker/appconf.conf index 6dbcc604..0dfec658 100644 --- a/client/docker/appconf.conf +++ b/client/docker/appconf.conf @@ -71,8 +71,8 @@ Header always set X-Content-Type-Options "nosniff" # requested under the /roles/ prefix (eg via the access dashboard) - Substitute "s|href=\"/|href=\"/roles/|gi" - Substitute "s|src=\"/|src=\"/roles/|gi" - Substitute "s|action=\"/|action=\"/roles/|gi" + Substitute "s|href=\"/|href=\"/roles/|i" + Substitute "s|src=\"/|src=\"/roles/|i" + Substitute "s|action=\"/|action=\"/roles/|i" From 882069f4120154b123efd97a3831a89adb645e83 Mon Sep 17 00:00:00 2001 From: Peter Havekes Date: Fri, 20 Nov 2026 15:38:27 +0100 Subject: [PATCH 4/4] Use relative base in vite build so assets work under a path prefix With base './' the built index.html references ./assets/... which the browser resolves against the current prefix (/ or /roles/), so no response rewriting is needed for asset URLs. --- client/vite.config.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/vite.config.js b/client/vite.config.js index 0624b8f2..8742cae3 100644 --- a/client/vite.config.js +++ b/client/vite.config.js @@ -21,6 +21,8 @@ export default defineConfig({ globals: true }, build: { + // relative asset URLs so the app also works under a path prefix (eg /roles/) + base: './', chunkSizeWarningLimit: 1000 }, server: {