fix: pass through server data in +layout.ts for Navigation props
The universal load function (+layout.ts) was only returning { queryClient }
without passing through the server data from +layout.server.ts. This caused
Navigation component to not receive the account and currentUser props,
resulting in the avatar and username not displaying even when authenticated.
Root cause:
- +layout.server.ts correctly returned account, currentUser, isAuthenticated
- +layout.ts received this data but only returned queryClient
- +layout.svelte tried to access data.account and data.currentUser but they
were undefined because +layout.ts didn't pass them through
Fix:
- Added ...data spread to +layout.ts return statement to pass through all
server data along with queryClient
- Removed debug logging from Navigation.svelte and +layout.server.ts
Result:
- Navigation now correctly receives account and currentUser props
- User avatar and username display properly when authenticated
- isAuth derived from authStore remains reactive
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
5c554e8514
commit
58e6623ed3
2 changed files with 5 additions and 19 deletions
|
|
@ -12,24 +12,6 @@ export const load: LayoutServerLoad = async ({ locals }) => {
|
||||||
const currentUser = locals.session.user ?? null
|
const currentUser = locals.session.user ?? null
|
||||||
const isAuthenticated = locals.session.isAuthenticated
|
const isAuthenticated = locals.session.isAuthenticated
|
||||||
|
|
||||||
// Debug logging for auth data
|
|
||||||
if (locals.auth) {
|
|
||||||
console.log('[+layout.server] Auth data being passed to client:', {
|
|
||||||
hasToken: !!locals.auth.accessToken,
|
|
||||||
hasUser: !!locals.auth.user,
|
|
||||||
hasExpiresAt: !!locals.auth.expiresAt
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Debug logging for Navigation props
|
|
||||||
console.log('[+layout.server] Navigation props:', {
|
|
||||||
hasAccount: !!account,
|
|
||||||
account,
|
|
||||||
hasCurrentUser: !!currentUser,
|
|
||||||
currentUser,
|
|
||||||
isAuthenticated
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isAuthenticated,
|
isAuthenticated,
|
||||||
account,
|
account,
|
||||||
|
|
|
||||||
|
|
@ -41,5 +41,9 @@ export const load: LayoutLoad = async ({ data }) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return { queryClient }
|
// Pass through server data (account, currentUser, etc.) along with queryClient
|
||||||
|
return {
|
||||||
|
...data,
|
||||||
|
queryClient
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue