T
TanStack5mo ago
eastern-cyan

Setting request headers

Hi, how do I set the request headers so that I can pass an Authorization token in requests to server functions?
6 Replies
blank-aquamarine
blank-aquamarine5mo ago
Middleware | TanStack Start React Docs
What is Server Function Middleware? Middleware allows you to customize the behavior of server functions created with createServerFn with things like shared validation, context, and much more. Middlewa...
blank-aquamarine
blank-aquamarine5mo ago
Using middleware
eastern-cyan
eastern-cyanOP5mo ago
Perfect, thank you! How do I register the global middleware? I have a global-middleware.ts file but I'm not using app/ as a directory. Ah, adding it to __root worked
blank-aquamarine
blank-aquamarine5mo ago
Yeah I think it used to auto pick it up but not anymore
other-emerald
other-emerald2mo ago
Sorry Im struggling in this section How were you able to add header to the request?
stormy-gold
stormy-gold2mo ago

Did you find this page helpful?