sveltejs / sveltejs/kit

Prioritization of static assets vs routes differs between client-side and server-side navigation

Open
#6,236 18 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

pkg:adapter-vercel
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the bug

I have a CMS dynamically creating pages in the routes folder [uri]/+page.svelte. The CMS contains all page data. Within sveltekit I override some pages for the purpose of unique styling. I should also note that this issue only occurs when trailingSlash: 'always' is set.

Accessing this URL directly shows data from the CMS
https://sveltekit-test-routes.vercel.app/about-us/

Clicking on the link on the homepage takes you to the hardcoded page within svelte which is the correct function
https://sveltekit-test-routes.vercel.app

This is a major issue as not only does it not work as intended it shows both pages two different ways

Reproduction

https://github.com/hartwm/sveltekit-test-routes/tree/main

Logs

No response

System Info
System:
    OS: macOS 12.2.1
    CPU: (10) x64 Apple M1 Pro
    Memory: 37.18 MB / 32.00 GB
    Shell: 5.1.4 - /usr/local/bin/bash
  Binaries:
    Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
  Browsers:
    Brave Browser: 104.1.42.86
    Chrome: 104.0.5112.101
    Edge: 104.0.1293.63
    Firefox: 103.0.2
    Safari: 15.3
Severity

serious, but I can work around it

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproduction repository, especially routes/[uri]/+page.svelte, the homepage link, and the trailingSlash: 'always' configuration. Compare direct loading of /about-us/ with client-side navigation from the homepage. Done means both navigation paths consistently select the intended hardcoded route rather than differing between CMS and SvelteKit page data.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.