Skip to content

fix: strip internal data before passing URL to reroute - #13092

Merged
dummdidumm merged 11 commits into
mainfrom
fix-reroute-invalidate
Jan 17, 2025
Merged

fix: strip internal data before passing URL to reroute#13092
dummdidumm merged 11 commits into
mainfrom
fix-reroute-invalidate

Conversation

@teemingc

@teemingc teemingc commented Dec 2, 2024

Copy link
Copy Markdown
Member

fixes #11625

This PR ensures that the /__data.json suffix, x-sveltekit-trailing-slash, and x-sveltekit-invalidated query param are stripped before passing a copy of the URL to reroute so that the URL can be correctly rerouted instead of causing a 404 due to the /__data.json pathname suffix.

If this PR gets merged, we will need a shared solution for the edge middlewares running reroute in #12296


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@changeset-bot

changeset-bot Bot commented Dec 2, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bcecf13

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@teemingc
teemingc marked this pull request as draft December 2, 2024 03:14
@teemingc
teemingc marked this pull request as ready for review December 2, 2024 05:44
@dummdidumm

Copy link
Copy Markdown
Member

If this PR gets merged, we will need a shared solution for the edge middlewares running reroute in #12296

To clarify: If we merge this, then we need to adjust the referenced PR to also deal with this case, but it's not something that forces our hand in other places?

@teemingc

Copy link
Copy Markdown
Member Author

If this PR gets merged, we will need a shared solution for the edge middlewares running reroute in #12296

To clarify: If we merge this, then we need to adjust the referenced PR to also deal with this case, but it's not something that forces our hand in other places?

We'd probably need to make the same adjustment if we need to run reroute in other places too. For now, it's only the Vercel and Netlify adapters that have to run reroute earlier to route to the correct split function. I don't think there are other adapters that would need the same changes since only Vercel and Netlify have the split option.

@Rich-Harris

Copy link
Copy Markdown
Member

preview: https://svelte-dev-git-preview-kit-13092-svelte.vercel.app/

this is an automated message

Comment thread packages/kit/src/runtime/server/respond.js Outdated
@dummdidumm
dummdidumm merged commit 6774ebc into main Jan 17, 2025
@dummdidumm
dummdidumm deleted the fix-reroute-invalidate branch January 17, 2025 10:37
@github-actions github-actions Bot mentioned this pull request Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failure to fetch /__data.json?x-sveltekit-invalidated on "rerouted" pages in development

3 participants