-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
Which project does this relate to?
Router
Describe the bug
Server middleware returning context values cannot be accessed on the loader or beforeLoad
Your Example Website or App
I couldn't finde a stackblitz with Tanstack Start. When I tried to install it, I get a lot of type errors.
Steps to Reproduce the Bug or Issue
Create a route with context like this:
import { createFileRoute } from "@tanstack/react-router";
import { createMiddleware } from "@tanstack/react-start";
const authMiddleware = createMiddleware().server(async ({ next }) => {
return next({
context: {
auth: {
isAuthenticated: true,
},
},
});
});
export const Route = createFileRoute("/$locale/_auth")({
server: {
middleware: [authMiddleware],
},
loader: ({ context }) => {
console.log(context);
},
});See in the log that isAuthenticated=false
Expected behavior
The log shows isAuthenticated=true
Screenshots or Videos
No response
Platform
"@tanstack/react-devtools": "^0.7.0",
"@tanstack/react-form": "^1.0.0",
"@tanstack/react-router": "^1.132.0",
"@tanstack/react-router-devtools": "^1.132.0",
"@tanstack/react-router-ssr-query": "^1.131.7",
"@tanstack/react-start": "^1.132.0",
"@tanstack/router-plugin": "^1.132.0",Additional context
PS: I couldn't find in the docs if beforeLoad runs in the client or the server. It would be nice to have better docs for that function
Metadata
Metadata
Assignees
Labels
No labels