-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Closed
Copy link
Description
Which project does this relate to?
Start
Describe the bug
When implementing a manual authentication procedure from the provided guide in the documentation, several issues arise. Notably, the useSession method is not functioning correctly. Below is the sample code I utilize and the corresponding error:
How session is configured:
// utils/tanstack-session.ts
"use server";
import { useSession } from "@tanstack/react-start/server";
export function useAppSession() {
return useSession({
name: "session",
password:
"LKMDSM<DCLMSCDKNScjdnskjdfn3434rmn3kj4n3kjrnk3j4nrkj34nrkj3nrkj3n4rkjn", // At least 32 characters
cookie: {
secure: false,
sameSite: "lax",
httpOnly: true,
maxAge: 7 * 24 * 60 * 60, // 7 days
},
});
}How is used:
// actions.ts
import { useAppSession } from "./utils/tanstack-session";
export async function getSessionAction() {
const session = await useAppSession();
if (!session.data) {
return null;
}
return session.data;
}here is the error I get:
Error: Invariant failed: expected content-type header to be set
There are some other issues with the docs regarding the manual authentication guide:
-
In the "2. Session Management" section, the provided code sample's wont work unless after adding a "use server" directive.
-
In the "3. Authentication Context" section, the usage of
useServerFnis incorrect:
Your Example Website or App
https://codesandbox.io/p/devbox/cranky-mayer-pl9r9f
Steps to Reproduce the Bug or Issue
- Go to "https://codesandbox.io/p/devbox/cranky-mayer-pl9r9f"
- In the CodeSandBox there's another error that I coud'nt figure out: "globalThis.process.getBuiltinModule is not a function"
- Download the project and run it locally
- Open the project, on the main page there's a butto which by clicking on it the action that uses the cookies would run hence causing the error
Expected behavior
This should work as expected and return the cookie, as it did previously.
Screenshots or Videos
Platform
- Router / Start Version: Router: 1.141.2 | Start: 1.141.3
- OS: macOS
- Browser: Chrome
- Browser Version: 143.0.7499.109
- Bundler: vite
- Bundler Version: 7.1.7
Additional context
No response
coderabbitai
Metadata
Metadata
Assignees
Labels
No labels