Enforce trailing slash through js

I need to enforce a trailing slash on all my website’s pages, otherwise the content looks messed up (the building chain is a bit complex; there are multiple repos that provide content to different sub domains the same main domain). Compare:

https://www.phenopype.org/gallery/ vs https://www.phenopype.org/gallery

I thought that the first function in this js file would take care of it (it does when I test my site locally), but after deployment it doesn’t work: https://www.phenopype.org/gallery/_static/js/custom.js?v=20423946

Note that I cannot use “prettify urls” because of the redirect that merges my subdomains: phenopype-lander/netlify.toml at main · phenopype/phenopype-lander · GitHub

Any thoughts or comments? Thanks!

Pretty URLs won’t have any effect on those redirects and should be the solution to your problem.

(sorry for the delay in responding)

that doesn’t do it - now the redirect doesn’t work anymore and all the links are broken. also, in the root (https://www.phenopype.org/gallery) the prettyfier doesn’t work

it works when I bypass the redirect and just access the page through the subdomain - e.g. https://www.gallery.phenopype.org/projects/qr-codes/

hey so this is not solved and it would be great if I could get some more support

which options do I have to enforce a trailing slash other than “prettify urls”, which is breaking my site?

You could use Edge Functions: ascorbic/slash-edge: Banish or add trailing slashes with a Netlify edge function (github.com)