Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@kampus/relay): attach ssr next-auth cookies to fetch req #631

Merged
merged 1 commit into from
Aug 11, 2023

Conversation

usirin
Copy link
Member

@usirin usirin commented Aug 11, 2023

Attach cookies to serverside next.js fetch requests to our gql server. browser does this automatically, but we need to do that manually at server.

@usirin usirin requested a review from a team as a code owner August 11, 2023 20:51
@vercel
Copy link

vercel bot commented Aug 11, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
kampus-gql ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 11, 2023 8:58pm
kampus-next ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 11, 2023 8:58pm
2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
kampus-pasaport ⬜️ Ignored (Inspect) Visit Preview Aug 11, 2023 8:58pm
kampus-ui ⬜️ Ignored (Inspect) Visit Preview Aug 11, 2023 8:58pm

@usirin usirin changed the title Next auth rsc cookies fix(@kampus/relay): attach ssr next-auth cookies to fetch req Aug 11, 2023
Copy link
Member

@rasitds rasitds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

// eslint-disable-next-line @typescript-eslint/no-var-requires
const nextHeaders = require("next/headers") as { cookies: () => ReadonlyRequestCookies };
headers.Cookie = nextHeaders.cookies().toString();
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @cansirin this should fix your problem for getting "null" sessions for server side requests.

@usirin usirin requested a review from cansirin August 11, 2023 21:01
@usirin usirin merged commit 566babc into dev Aug 11, 2023
2 checks passed
@usirin usirin deleted the next-auth-rsc-cookies branch August 11, 2023 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants