Clerk API Routes protection on the server

Hi Everyone. I'm working on an app where I have a separate backend. To hide it from the end user, I'm using Next api routes as BFF. The problem is, even though server components read the authenticated user details, when I call an internal API route, it fails to fetch the user from Clerk. I've made sure and Clerk middleware sees the calls, but the auth object properties in afterAuth are all null. Any ideas? As an additional question, something's been bugging me. I'm using React Query to fetch and revalidate data and I use the hydration method on the server, then I fetch the data again on the client with the same key. That said, it's never fresh in tanstack query devtools. No matter whether cache/stale times are set or not and how I fiddle with them, immediately after refetching, data shows as stale, not fresh. Any idea why it is? Is it a bug or does it mean my setup is wrong?
0 Replies
No replies yetBe the first to reply to this messageJoin