T
TanStack6mo ago
correct-apricot

Cannot read properties of undefined (reading 'config')

Whenever I'm navigating in the project I'm getting the error from the title. It seems to be caused by the beforeLoad from __root.tsx The code:
beforeLoad: async () => {
const headers = getHeaders() // THIS LINE GETS HIGHLIGHTED AS AN ERROR
const data = await auth.api.getSession({
headers
})

return {
user: data?.user,
session: data?.session,
};
},
beforeLoad: async () => {
const headers = getHeaders() // THIS LINE GETS HIGHLIGHTED AS AN ERROR
const data = await auth.api.getSession({
headers
})

return {
user: data?.user,
session: data?.session,
};
},
I'm using better-auth for authentication purposes.
1 Reply
unwilling-turquoise
unwilling-turquoise6mo ago
needs to be wrapped in a server function

Did you find this page helpful?