houdini
houdini copied to clipboard
Having a +layout.server.ts file makes the client session undefined
Describe the bug
Having a +layout.server.ts file in routes, even if it's empty, makes the client session undefined from this:
// file - client.ts
import { HoudiniClient } from '$houdini';
import { PUBLIC_GRAFBASE_API_URL } from '$env/static/public';
export default new HoudiniClient({
url: PUBLIC_GRAFBASE_API_URL,
fetchParams({ session }) {
console.log("session", session)
return {
headers: {
Authentication: `Bearer ${session?.authToken}`,
},
}
return {}
},
})
Severity
annoyance
Steps to Reproduce the Bug
Put file +layout.server.ts file in routes
Reproduction
No response
Having the same problem.. :(
@saveliy-kremen
Maybe it helps you. https://discord.com/channels/1024421016405016718/1131236758890233977
I tried this solution. The session appears in PageData. But it still disappears in client.ts. As far as I understand, +layout.server.ts overwrites the session that hooks.server.ts sets. It would be nice to supplement the documentation on how to proceed in this case.
Any fix on this ? pretty much renders the client useless for most of my projects
I'm not able to reproduce this in the project's e2e tests. I'm going to close this since it doesn't seem to be widely spread but If you have the time to put together a reproduction, i'd gladly take a closer look