codebird
codebird•2mo ago

Convex Auth error with Nextjs 15

Just upgraded the Convex v1 starter kit to "next": "15.1.3" ( "@auth/core": "^0.37.4") and it showed the following error- Unhandled Runtime Error [ Server ] Error: {"code":"InvalidAuthHeader","message":"Could not parse as id token"} async Layout ./src/app/%5Blocale%5D/(dashboard)/layout.tsx Made a couple of changes, but still the error persists- 1. Added await in the layout file- token: await convexAuthNextjsToken(), similarly in middleware file- https://github.com/get-convex/v1/blob/main/apps/app/src/app/%5Blocale%5D/(dashboard)/layout.tsx 2. Added a new isAuthenticated endpoint to the list of exported Convex functions, like export const { auth, signIn, signOut, store, isAuthenticated } = convexAuth(... as described here https://github.com/get-convex/convex-auth/blob/main/CHANGELOG.md What else can be done?
GitHub
v1/apps/app/src/app/[locale]/(dashboard)/layout.tsx at main · get-c...
An open-source starter kit based on Midday. Ported to Convex. - get-convex/v1
GitHub
convex-auth/CHANGELOG.md at main · get-convex/convex-auth
Library for built-in auth. Contribute to get-convex/convex-auth development by creating an account on GitHub.
8 Replies
Convex Bot
Convex Bot•2mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
ballingt
ballingt•2mo ago
@codebird thanks for reporting, what version of @convex-dev/auth are you using? This could be a missing await, could you share the headers of that request? Any TypeScript errors? Sounds like we can upgrade this template to avoid other folks running into this.
codebird
codebirdOP•2mo ago
Versions "@auth/core": "^0.37.4", "@convex-dev/auth": "^0.0.78", There were Typescript errors initially, but they went away after await
codebird
codebirdOP•2mo ago
Here you go
No description
codebird
codebirdOP•2mo ago
Console
No description
codebird
codebirdOP•2mo ago
Error
No description
ballingt
ballingt•2mo ago
@codebird The header I'm interested in is the one causing the InvalidAuthHeader error This code
const user = await fetchQuery(
api.users.getUser,
{},
{ token: convexAuthNextjsToken() },
);
const user = await fetchQuery(
api.users.getUser,
{},
{ token: convexAuthNextjsToken() },
);
this needs an await, did you already add this? the return value of convexAuthNextjsToken() is the thing it'd be interesting to see, if you're not awaiting it then that's the problem, but if you are now then it sounds like it's a bad value
codebird
codebirdOP•2mo ago
I did add await there, but didn't work earlier. But it is working now. Strange. Thanks for the input anyway 🙂
No description

Did you find this page helpful?