Skip to content

Non-existent __data.json pages link to broken relative paths #11353

@teemingc

Description

@teemingc

Describe the bug

When navigating to a non-existent page with the data suffix e.g., /example/__data.json, the error page fails to load the js and css assets. This is happening because we strip the data suffix in the request URL.

url.pathname =
strip_data_suffix(url.pathname) +

So, the asset relative paths are returned one directory short when SvelteKit thinks the request URL is /example instead of /example/__data.json.

Reproduction

  1. Open https://stackblitz.com/edit/sveltejs-kit-template-default-lwxx8r?file=README.md
  2. Run pnpm build && pnpm preview
  3. Navigate to /anything/__data.json

Expected: Ordinary styled error page.

Actual: Unstyled error page.

Logs

No response

System Info

stackblitz

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions