Skip to content

trailingSlash option not working correctly or consistently in SvelteKit 2 #11382

@CaptainCodeman

Description

@CaptainCodeman

Describe the bug

A static site using +layout.ts

export const prerender = true
export const trailingSlash = 'never'

Navigating to the website includes a trailing '/' (due to gh pages 301 redirect):
https://captaincodeman.github.io/svelte-headlessui/

Inspecting a link shows the correct URL in the HTML without any trailing slash (also when viewing page source):
Screenshot 2023-12-18 at 7 47 39 AM

But clicking the link takes you to the URL with the trailing slash added:
https://captaincodeman.github.io/svelte-headlessui/combobox/

This causes relative paths to be incorrect (in this case, an iframe src) resulting in a 404:
Screenshot 2023-12-18 at 7 52 21 AM

Have tried every combination of paths.relative and trailingSlash, all fail in some way.

Removing the trailing slash manually (on a non root page) fixes the rendering and also subsequent navigation.

Reproduction

Live site: https://captaincodeman.github.io/svelte-headlessui/combobox/

Source: https://github.com/CaptainCodeman/svelte-headlessui

Logs

No response

System Info

System:
    OS: macOS 14.2
    CPU: (6) x64 Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz
    Memory: 66.75 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.6.1 - ~/Library/pnpm/node
    npm: 9.8.1 - ~/Library/pnpm/npm
    pnpm: 8.12.1 - ~/Library/pnpm/pnpm
    bun: 1.0.0 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 106.1.44.112
    Chrome: 120.0.6099.109
    Chrome Canary: 122.0.6192.0
    Safari: 17.2
    Safari Technology Preview: 17.4
  npmPackages:
    @sveltejs/adapter-static: ^3.0.0 => 2.0.3 
    @sveltejs/kit: ^2.0.1 => 1.26.0 
    svelte: ^4.2.8 => 4.2.2 
    vite: ^5.0.10 => 4.5.0

Severity

blocking an upgrade

Additional Information

Most routes use a [...slug] route.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpaths.basebugs relating to `config.kit.paths.base`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions