Next.js Discord

Discord Forum

State cookie was missing.

Unanswered
New Zealand Heading Dog posted this in #help-forum
Open in Discord
New Zealand Heading DogOP

7 Replies

New Zealand Heading DogOP
What can i do guys? idk about this error.
@New Zealand Heading Dog What can i do guys? idk about this error.
try disabling this check in your google provider
DiscordProvider({
      clientId: ...,
      clientSecret: ...,
      checks: ['none']
    })
// in your google provider
@gin https://github.com/nextauthjs/next-auth/discussions/7491#discussioncomment-6166539
New Zealand Heading DogOP
Hey thank you, i've got a different problem now, after i log in, i'm being redirected to this URL: http://localhost:3000/login?callbackUrl=http%3A%2F%2Flocalhost%3A3000%2Fportal
It's just the Log in page again.
import { NextAuthOptions } from "next-auth";
import GoogleProvider from "next-auth/providers/google";
import { PrismaAdapter } from "@auth/prisma-adapter";
import { Adapter } from "next-auth/adapters";
import prisma from "@/lib/prisma";

export const authOptions: NextAuthOptions = {
 
  adapter: PrismaAdapter(prisma) as Adapter,
  providers: [
    GoogleProvider({
      clientId: process.env.GOOGLE_CLIENT_ID as string,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
    }),
  ],
  secret: process.env.NEXTAUTH_SECRET as string,
  pages: {
    signIn: "/login",
  },
  session: {
    strategy: "jwt",
  },
  jwt: {
    secret: process.env.NEXTAUTH_JWT_SECRET as string,
  },
  callbacks: {
    async signIn({ user }) {
      if (!user.email?.endsWith(process.env.ALLOWED_DOMAIN as string)) {
        throw new Error("You are not allowed to access this platform");
      }
      return true;
    },

    jwt: async ({ token, user }) => {
      if (user) {
        token.role = user.role;
      }
      return token;
    },
    async session({ session, token }) {
      if (session.user) {
        session.user.role = token.role;
      }
      console.log(session)
      return session;
    },
    
  },
  
};


Here's the Button, Google console setup and the auth.ts