Adding trailing slash to shiny app

Hi,
I'm trying to render a shiny app (in docker swarm mode) using traefik, but the app does not render fully without the trailing slash.
I've tried modifying the docker compose yml file to add a trailing slash but still the app does not render - it only renders fully when a slash (/) is manually added to the URL in the browser.

I've been trying to resolve this for ages without any success.

Any feedback would be appreciated.

Here are the labels in my current yml file:

     - "traefik.enable=true"
     - "traefik.docker.network=test_net2"
     - "traefik.http.routers.app.entrypoints=web"   
     - "traefik.http.routers.app.rule=Host(`domain.com`, `www.domain.com`) && PathPrefix(`/app`)" 
     - "traefik.http.middlewares.app.stripprefix.prefixes=/app"
     - "traefik.http.routers.app.middlewares=app@docker"
     - "traefik.http.services.app.loadbalancer.server.port=3838"
     - "traefik.http.services.app.loadbalancer.sticky=true"
     - "traefik.http.services.app.loadbalancer.sticky.cookie.name=stickycookie"       
     - "traefik.http.services.app.loadbalancer.sticky.cookie.secure=true" 
     - "traefik.http.routers.app.entrypoints=websecure"
     - "traefik.http.routers.app.tls=true"
     - "traefik.http.routers.app.tls.certresolver=le"

I'm using traefik:2.5.3

The above code enables the app to be fully rendered at domain.com/app/, but not domain.com/app

I've tried the following and it makes not difference to the above:

     - "traefik.frontend.redirect.regex=^(.*)/app$$"
     - "traefik.frontend.redirect.replacement=$$1/app"
     - "traefik.frontend.rule=PathPrefix:/app;ReplacePathRegex: ^/app(.*) /$$1"

I've visited many web pages and tried various middlewares

I recommend to update to a recent Traefik version (v2.10) and use something like traefik/whoami to check the path received by the target service.

Note hat it is not best practice to have an app with a PathPrefix and StripPrefix, as the app might return paths in html like /js/script.js which will not work with your setup. Best practice for apps is to use a sub-domain.

I can get the apps to render by specifying the subdomains (copied below for reference).

It would be nice to be able to get Docker swarm Shiny apps to work with an appended path to the domain, but will use subdomain for the timebeing. Thanks.

     - "traefik.enable=true"
     - "traefik.docker.network=test_net2"
     - "traefik.http.routers.app.entrypoints=web"   
     - "traefik.http.routers.app.rule=Host(`app.domain.com`)"
     - "traefik.http.middlewares.app.stripprefix.forceSlash=false"
     - "traefik.http.routers.app.middlewares=app@docker"
     - "traefik.http.services.app.loadbalancer.server.port=3838"
     - "traefik.http.services.app.loadbalancer.sticky=true"
     - "traefik.http.services.app.loadbalancer.sticky.cookie.name=stickycookie"       
     - "traefik.http.services.app.loadbalancer.sticky.cookie.secure=true" 
     - "traefik.http.routers.app.entrypoints=websecure"
     - "traefik.http.routers.app.tls=true"
     - "traefik.http.routers.app.tls.certresolver=le"