[Next.js] AuthRequiredError when calling Data API with createNeonAuth session token
NeonNode.js❓Question
I am using Next.js 15 (App Router). I need to securely query my Neon database from Server Actions with authentication. I am using the official @neondatabase/auth and @neondatabase/neon-js packages. My approach is to retrieve the session using auth.getSession(), extract the token, and inject it as an Authorization: Bearer header into the global fetch options of the Data API client.
Logs and Error Messages: When executing a simple query the Data API rejects the request.
What I've already tried: 1. Passing the raw Next.js cookieStore.toString() directly into the cookie header of the Data API fetch options (failed). 2. Extracting the token from auth.getSession() and passing it as a Bearer token (my current approach, still failing). 3. Verifying all environment variables (NEON_AUTH_BASE_URL, NEON_DATA_API_URL, etc.) are correctly set.
My Question: What is the recommended approach to link the session from createNeonAuth to the createClient Data API config? Does the Data API expect a different header format, am I missing a configuration step?