-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
It seems to me that prefetching is breaking the redirects I am using, when my user isn't logged in but should be.
Basically what happens is that when I hover over the link, it seems that the remote function is immediately triggered by the prefetch, and the redirect fires. You can see it in the address bar, which shows the address the redirect points to.
Thing is, I haven't clicked yet. When I now click on the link, the redirect is already "spent", and I end up on the page that I wanted to protect. Only if I now fully reload the page, I am redirected.
When I disable prefetching on that link, it works as intended.
Reproduction
component.svelte:
<script>
import { call } from './fetch.remote'
</script>
await call()
fetch.remote.js:
export const call = query(async () =>
{
redirect(307, '/some-other-route')
})
Logs
System Info
System:
OS: Linux 6.6 Ubuntu 24.04.3 LTS 24.04.3 LTS (Noble Numbat)
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
Memory: 10.78 GB / 15.48 GB
Container: Yes
Shell: 5.9 - /usr/bin/zsh
Binaries:
Node: 24.8.0 - /home/andreas/.nvm/versions/node/v24.8.0/bin/node
npm: 11.6.2 - /home/andreas/.nvm/versions/node/v24.8.0/bin/npm
Browsers:
Chrome: 141.0.7390.107
npmPackages:
@sveltejs/adapter-auto: ^7.0.0 => 7.0.0
@sveltejs/kit: ^2.47.1 => 2.48.5
@sveltejs/vite-plugin-svelte: ^6.2.1 => 6.2.1
svelte: ^5.41.0 => 5.43.7
vite: ^7.1.10 => 7.2.2Severity
serious, but I can work around it
Additional Information
No response
dangodai
Metadata
Metadata
Assignees
Labels
No labels