-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auth doesn't work in Server Actions in NextJS #1537
Comments
That's extremely odd, as this is working for me. I'm on nextjs canary You'll need to do npm install --force next@canary This is because Clark has a dependency on the version number and it doesn't recognize this experimental version. I should also mention it's basically real time updates to nextjs. async function fetchLessonsFromDBByStudentId(id: string) {
const user = await currentUser();
const records = await prisma.$queryRaw(sqltag`
SELECT lesson.lesson_id, name, description, lesson_datetime, created_by, created_on, updated_by, updated_on
FROM lesson
WHERE created_by = ${user?.id}
AND lesson.lesson_id IN (
SELECT lesson_id
FROM lesson_participant
WHERE user_id = ${id})`) as unknown as Array<Lesson>
return records ?? []
}
import { getStudentLessons as getStudentLessonsDB, getTutorLessons as getTutorLessonsDB } from "@/lib/helpers";
export async function getStudentLessons(data: BaseData) : Promise<Array<Lesson>> {
return getStudentLessonsDB(data.user_id);
}
|
I found a similar looking issue that may be related. |
Hey friends - just want to let you know that we're looking into this. So sorry for the long delay 😞 |
Our most recent tests with server actions were working - is there any chance that someone would be willing to create a minimal reproduction for us on this one? 🙏 |
Hello 👋 We currently close issues after 40 days of inactivity. It's been 30 days since the last update here. If we missed this issue, please reply here. Otherwise, we'll close this issue in 10 days. As a friendly reminder: The best way to see an issue fixed is to open a pull request. If you're not sure how to do that, please check out our contributing guide. Thanks for being a part of the Clerk community! 🙏 |
Hello again 👋 After 40 days of no activity, we'll close this issue. Keep in mind, I'm just a robot, so if I've closed this issue in error, please reply here and my human colleagues will reopen it. As a friendly reminder: The best way to see an issue fixed is to open a pull request. If you're not sure how to do that, please check out our contributing guide. Thanks for being a part of the Clerk community! 🙏 |
in case anyone else runs into this.... import { auth } from '@clerk/nextjs/server'; |
Hi there! "dependencies": { I'm running into all foruns that is talking about it, because i'm still facing this problem using clerk helpers with server side components..... Every time i try to access the user info, using auth or currentUser, it returns null for me. But, if i call it on a client side component, it works perfectly.....please, someone can help me?? |
@Leonardo-Mazzuca identical situation |
In fact - this is happening at exactly the same time for both of us, which makes me think this might be a Clerk server problem |
Hi @Leonardo-Mazzuca and @raph90 can you open a separate issue with a minimal reproduction if possible? Thanks! |
@BRKalow I don't have time to create a proper issue unfortunately - I can if this problem persists. But basically doing this:
is returning null on the server, even though there is an active session. I just thought it was interesting that Leonardo and I commented the same thing so close together (the post previously was August 1) EDIT if it helps, I'm running:
|
@Leonardo-Mazzuca Craziest thing but I'm leaving this here just in case this happens to anyone else. DO NOT set an environment variable called Took me a good few hours to find that one... |
Oh gosh, a small thing that made u lost a lot of time. But well done my friend, good that u found that issue😁 |
Package + Version
@clerk/clerk-js
@clerk/clerk-react
@clerk/nextjs
@clerk/remix
@clerk/types
@clerk/themes
@clerk/localizations
@clerk/clerk-expo
@clerk/backend
@clerk/clerk-sdk-node
@clerk/shared
@clerk/fastify
@clerk/chrome-extension
gatsby-plugin-clerk
build/tooling/chore
Dependencies + versions
Description
Per documentation, I am trying to get user data inside Server Actions. I have app router and I tried both "auth" and "currentUser" inside my server actions, which are created in app/actins, they work for calling other apis but not clerk and the error that I'm getting is:
and the code that I tried was from 'Server Actions' tab:
The text was updated successfully, but these errors were encountered: