Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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/

15 changes: 15 additions & 0 deletions client/docker/appconf.conf
Original file line number Diff line number Diff line change
@@ -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/?$ /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$
RewriteCond %{REQUEST_URI} !\.png$
Expand Down Expand Up @@ -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)
<IfModule mod_substitute.c>
<If "reqenv('ROLES_PREFIX') == '1'">
Substitute "s|href=\"/|href=\"/roles/|i"
Substitute "s|src=\"/|src=\"/roles/|i"
Substitute "s|action=\"/|action=\"/roles/|i"
</If>
</IfModule>
2 changes: 2 additions & 0 deletions client/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Loading