houdini icon indicating copy to clipboard operation
houdini copied to clipboard

Having a +layout.server.ts file makes the client session undefined

Open saveliy-kremen opened this issue 2 years ago • 4 comments

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

saveliy-kremen avatar Jun 14 '23 14:06 saveliy-kremen

Having the same problem.. :(

mcavaciocchi avatar Jul 19 '23 12:07 mcavaciocchi

@saveliy-kremen

Maybe it helps you. https://discord.com/channels/1024421016405016718/1131236758890233977

mcavaciocchi avatar Jul 19 '23 16:07 mcavaciocchi

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.

saveliy-kremen avatar Jul 20 '23 06:07 saveliy-kremen

Any fix on this ? pretty much renders the client useless for most of my projects

zx8086 avatar Nov 09 '23 00:11 zx8086

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

AlecAivazis avatar Jul 07 '24 08:07 AlecAivazis