Next.js Discord

Discord Forum

Auth.js "missing CSRF token"

Unanswered
New Guinea Singing Dog posted this in #help-forum
Open in Discord
New Guinea Singing DogOP
Im using Auth.js for authentication but whenever I try to log in to github using my custom /signin page, I get an error on the server side saying that "CSRF token was missing during an action signin". I've gone to the website for help but I found nothing. Here is my signin page (i linked it in the auth.js).
import { signIn } from '@/auth'

export default function Page() {
  return (
    <div className="flex items-center justify-center min-h-screen">
      <div className="flex flex-col gap-4 p-8 bg-zinc-800 shadow rounded-xl max-w-sm">
        <h2 className="font-bold text-2xl">Sign In</h2>
            <form 
              action={async () => {
                'use server'
                signIn('github', { redirect: true, redirectTo: '/dashboard' })
              }}
            >
              <button className="py-2 px-4 shadow rounded bg-zinc-300 hover:bg-zinc-400 active:bg-zinc-500 text-zinc-900 transition-colors duration-150" type="submit">Sign in with Github</button>
            </form>
          )
      </div>
    </div>
  )
}

3 Replies

Short-tailed Albatross
hi hi
im facing hte same thing, its been 2 days
was wondering if you figured something out ?