#Error: Invariant: missing action ID.

41 messages · Page 1 of 1 (latest)

plain walrus
#

I'm getting this error while redirecting to a page after form submit

#

It was not happening before 13.2

winged pendant
#

I encountered same issue

plain walrus
#

it is the way you redirect, you have to do it the old way

winged pendant
#

mhh

#
        const result = await signIn("credentials", {
            username: userName.current,
            password: pass.current,
            redirect: false,
            callbackUrl: "/",
        });```
#

i'm not even redirecting

plain walrus
#

oh

#

how the hell are you getting this error?

#

are you trying to access what endpoint?

winged pendant
#

nextauth

#
import NextAuth, { NextAuthOptions } from 'next-auth';
import { MongoDBAdapter } from '@next-auth/mongodb-adapter';
import clientPromise from '../../../lib/mongodb';
import CredentialsProvider from 'next-auth/providers/credentials';
import { compare } from 'bcrypt';
import dbConnect from '../../../lib/dbConnect';
import User from '../../../model/User';


export const authOptions: NextAuthOptions = {
  adapter: MongoDBAdapter(clientPromise),
  providers: [
    CredentialsProvider({
      id: 'credentials',
      name: 'Credentials',
      credentials: {
        email: {
          label: 'Email',
          type: 'text'
        },
        password: {
          label: 'Password',
          type: 'password'
        }
      },
      async authorize(credentials) {
        await dbConnect();

        // Find user with the email
        const user = await User.findOne({
          email: credentials?.email
        });

        // Email Not found
        if (!user) {
          console.log("test");
        }

        // Check hased password with DB hashed password
        const isPasswordCorrect = await compare(
          credentials!.password,
          user.hashedPassword
        );

        // Incorrect password
        if (!isPasswordCorrect) {
          console.log("test");
          
        }

        return user;
      }
    })
  ],
  pages: {
    signIn: '/auth'
  },
  debug: process.env.NODE_ENV == 'development',
  session: {
    strategy: 'jwt'
  },
  jwt: {
    secret: process.env.NEXTAUTH_JWT_SECRET
  },
  secret: process.env.NEXTAUTH_SECRET
};

export default NextAuth(authOptions);
plain walrus
#

I'm using the default implementation so I cant help you with that

winged pendant
#

Idk what is happening

#

should downgrade ?

plain walrus
#

No

#

Use t3-stack

#

I can help you with that if you need

#

Do you have a specific reason for using JWT?

winged pendant
#

Okay; but why using t3?

#

yeah, i'll access to this api from other application

plain walrus
#

and there is no problem for accessing anything

winged pendant
#

okay i'll work around this solution

plain walrus
#

Okay, sorry for not helping you with that, our errors are not the same :C

winged pendant
#

i'll check for t3

plain walrus
#

You will have no issue at all with the out-of-the-box implementation for NextAuth

winged pendant
#

I used nextauth because it's easier solution for just some log

plain walrus
#

t3 is just a stack with some tweaks, it uses NextAuth

#

(under the hood)

winged pendant
#

Okay, I have to check how implement it, and how I can use it with mongoose etc

plain walrus
#

WARN: t3 stack implementation for NextAuth is based at platform logins (Ex: Google, Discord, Github, etc.), It will not work with Credentials (Email/Password)

winged pendant
#

oh

plain walrus
winged pendant
#

So I have to recreate my entire app x)

plain walrus
#

Imo you will have much more headache using mongoose than writing a prisma schema in 3 minutes

#

(I used mongoose for 2 years in a row)

winged pendant
#

But I have to make credentials working