Removing trailing slash on static websites


I published a static website (Nuxt 3) on Cloudflare pages. The problem is that it automatically adds a trailing slash at the end of some URLs, creating some nasty 308 redirects which completely break my linking for SEO.

Ex: =>

Is there a way to disable that? I searched for 30 minutes and no solution was provided in any of the topics already posted.

This behavior is documented here: Serving Pages · Cloudflare Pages docs and cannot be disabled.

There are workarounds with how you can name your files: Why We Switched CDNs: How Google's Core Web Vitals Led Us to Cloudflare Pages - Electric UI, but nothing easy. If you do /contact.html instead of /contact/index.html, it becomes /contact and not /contact/, and /contact/, /contact.html would redirect back to /contact

That’s annoying… I can’t control how the files are named so it’s a no-go for me (and all Nuxt users).

I guess I’ll have to find another host

Edit: Found a solution even if an option to control trailing slashes would be better

Add this to nuxt.config.js:

nitro: {
        prerender: {
            autoSubfolderIndex: false,

Will generate blog.html instead of blog/index.html, which don’t have trailing slashes