You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was having some simple redirect logic in my application in +layout.ts:
export const load = async ({ data, url }) => {
const { user } =data|| {};
if (user&&url.pathname==='/login') {
throwredirect(302, '/');
}
if (!user&&url.pathname!=='/login') {
throwredirect(302, '/login');
}
return {
user
};
};
After updating to @sveltejs/[email protected], the app was fully reloading when navigating instead of client side routing. After some investigation I found out that using url in +layout causes the data passed from +layout.server to be cleared.
In the example below I am just logging url.pathname in +layout and displaying the data in the Home page. When navigating from and the back to the home page; the data is cleared. That won't happen if console.log(url.pathname) is removed from +layout.
Describe the bug
I was having some simple redirect logic in my application in +layout.ts:
After updating to @sveltejs/[email protected], the app was fully reloading when navigating instead of client side routing. After some investigation I found out that using url in +layout causes the data passed from +layout.server to be cleared.
In the example below I am just logging url.pathname in +layout and displaying the data in the Home page. When navigating from and the back to the home page; the data is cleared. That won't happen if console.log(url.pathname) is removed from +layout.
Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-bdr4bj?file=src/routes/+layout.js
Logs
No response
System Info
Severity
blocking an upgrade
Additional Information
No response
The text was updated successfully, but these errors were encountered: