Removing Trailing Slashes with Astro
I have deployed a couple of sites with Astro on Cloudflare but both have been in ssr mode. Specifically, with directory mode on Cloudflare:
// astro.config.mjs for ssr
{
...,
adapter: cloudflare({ mode: 'directory' }),
}
However, for this site, I deployed using static mode (ssg) and deployed on cloudflare. The builds and deployments were fine but I noticed my urls had a trailing slash that I wanted to remove. After some head scratching and experimenting, I found the fix to be to update the config for build format to file.
Per the docs, The default value is directory so updating this to file and adding the trailingSlash to never did the trick.
// astro.config.mjs for ssg
{
...,
trailingSlash: 'never',
build: {
format: 'file',
},
}