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
Error: Invariant: headers() expects to have requestAsyncStorage, none available. #9192
Comments
I'm experiencing the same error with Auth0 provider, it happens when I click on this button rendered on root page.tsx 'use client'
import { Session } from 'next-auth'
import { signIn, signOut } from '../../auth'
const LoginButton = () => {
return (
<button
style={{ marginRight: 10 }}
onClick={() => signIn('auth0')}
className="text-white"
>
Log in <span aria-hidden="true">→</span>
</button>
)
} |
i think they change to server action that why we have this problem. you can use it as server action. but the error message i am not sure |
Folowed Upgrade Guide (v5) and got the same issue with |
The |
Create Server action add 'use server' at the top and Call the function. |
I got this error because I was following this tutorial from Vercel on adding authentication with |
hey, I use Apollo-Graphql and next-auth in this code, I try to pass the user token to the server with "setContext", but I got such an error: before I clicked on the card (I mean the user card), everything worked fine, and the token was passed to the server, that error appeared after a click on the card.
|
Same error with tRPC and server actions |
/**
* https://github.com/nextauthjs/next-auth/issues/9192
*/
import { auth, signIn, signOut } from "~/libs/auth";
export const Form: React.FC = async () => {
const au = await auth();
if (au === null) {
return (
<div>
<h1>Not LoggedIn!</h1>
<div>
<h2>Admin</h2>
<form
action={async () => {
"use server";
await signIn("credentials", {
email: "jonsoku.dev@gmail.com",
redirect: false,
});
}}
>
<button type="submit">Admin User</button>
</form>
<h2>Common</h2>
<form
action={async () => {
"use server";
await signIn("credentials", {
email: "jonsoku.dev2@gmail.com",
redirect: false,
});
}}
>
<button type="submit">Common User</button>
</form>
</div>
</div>
);
}
return (
<div>
<div>{JSON.stringify(au, null, 2)}</div>
<div>
<form
action={async () => {
"use server";
await signOut();
}}
>
<button type="submit">Sign out</button>
</form>
</div>
</div>
);
}; it is work |
I was simply redirecting to In my case, however, I had to disable Turbopack (i.e., Commenting here just in case anybody else ran into a similar issue. |
If i move the code from client to server action:
then i got : if i keep it client then i got
so no idea what to do using: |
Loved this, no extra work, I was following the tutorial as well: https://nextjs.org/learn/dashboard-app/adding-authentication |
This works for me. Update the import for the auth. Also update the code to include all (or only) the providers your app needs. You can then import and use in any component. "use server";
import { signIn as authSignIn } from "../../app/auth";
export const signIn = async (provider: "instagram" | "tiktok" | "youtube") => {
await authSignIn(provider);
}; |
Environment
auth-js beta
Reproduction URL
https://github.com/nextauthjs/next-auth-example
Describe the issue
import { signIn, signOut } from "@/auth"
signIn("credentials", {
email,
password,
redirect: false,
})
How to reproduce
it would be nice if you can give me example and also how to handle custom error messsage
Expected behavior
it should work the way before but dont know maybe i miss doc
The text was updated successfully, but these errors were encountered: