Don't add trailing slash

I’m hosting a static website on Pages, with this rule in my webpack config that just copies my index.html a bunch of times to

ansible/index.html
cfml/index.html
and so on:

  plugins: [
    new MiniCssExtractPlugin(),
    new CopyPlugin({
      patterns: [
        'index.html',
        { from: 'index.html', to: 'ansible' },
        { from: 'index.html', to: 'cfml' },
        { from: 'index.html', to: 'dart' },
        { from: 'index.html', to: 'elixir' },
        { from: 'index.html', to: 'go' },
        { from: 'index.html', to: 'java' },
        { from: 'index.html', to: 'javascript' },
        { from: 'index.html', to: 'json' },
        { from: 'index.html', to: 'node-fetch' },
        { from: 'index.html', to: 'node-axios' },
        { from: 'index.html', to: 'node-request' },
        { from: 'index.html', to: 'matlab' },
        { from: 'index.html', to: 'php' },
        { from: 'index.html', to: 'python' },
        { from: 'index.html', to: 'r' },
        { from: 'index.html', to: 'rust' },
        { from: 'index.html', to: 'strest' },
        { from: 'images', to: 'images' },
      ]
    })

The idea being that users can open example.com/ansible, example.com/cfml and so on, and JavaScript loaded by index.html can extract the language from the path and do something with it.

This works fine when I run it locally with npm start, I can directly open locahost:8080/python or click around on links like <a href="/python">Python</a> but after deploying my site, because Cloudflare “helpfully” adds a trailing / to my URLs, it breaks.

The actual issue seems to be that I have JavaScript code that requests “my-file.wasm” which is normally hosted at “/my-file.wasm” but for some reason the request is now for /python/my-file.wasm and it actually gets index.html at that path instead… This doesn’t happen locally, so I suspect the issue has to do with the trailing slash?

I tried adding this rule, as suggested by this thread Page rule, how to not have trailing slash!?

but that just doesn’t work, clicking a link to example.com/foo just doesn’t do anything with that rule? The URL stays the same, even though clicking updates it using JavScript…

The site is Convert curl commands to code if you want to take a look

I think the rule not working may’ve been a caching issue. I disabled the rule then it started working (i.e. not adding a slash) but loading the site in incognito mode I still got the old behavior. I re-enabled the rule and I guess I’ll wait longer this time before disabling it.

Overall, this is dumb behavior. People that need a trailing slash should be the ones write page rules to get it, not me. My static site should work the way it works locally.

Sorry about that, you should be ok to now, lmk if not.