TanStackT
TanStack2mo ago
11 replies
unique-blue

Error: Cannot read properties of undefined (reading 'auth')

Copying the clerk auth example line for line and

const fetchClerkAuth = createServerFn({ method: "GET" }).handler(async () => {
  const { userId } = await auth();

  return {
    userId,
  };
});


Fails with Error: Cannot read properties of undefined (reading 'auth')
Seemingly:

// src/server/auth.ts
var auth = (async (opts) => {
  const authObjectFn = getGlobalStartContext().auth;
  if (!authObjectFn) {
    return errorThrower.throw(clerkMiddlewareNotConfigured);
  }
  const authObject = await Promise.resolve(authObjectFn({ treatPendingAsSignedOut: opts?.treatPendingAsSignedOut }));
  return getAuthObjectForAcceptedToken({ authObject, acceptsToken: opts?.acceptsToken });
});


getGlobalStartContext() is undefined - why?
Was this page helpful?