Next auth Error
Unanswered
Pradip Chaudhary posted this in #help-forum
I am using next auth credentials and custom signin page. But when I call signIn function, it redirects to error page with this message in error, don't know what it means.
16 Replies
@Pradip Chaudhary I am using next auth credentials and custom signin page. But when I call signIn function, it redirects to error page with this message in error, don't know what it means.
Did you configure the
NEXTAUTH_URL
variable in your .env
file?Yes
@Pradip Chaudhary Yes
Check that you did it correctly, so no typos, correct URL and so on
I have done it correctly but I look at it once again though
But I wanted to ask one thing.
In the error it is calling /api/auth/providers so is it correct ? Isn't there anything like it should have been */providers/credentials or anything
But I wanted to ask one thing.
In the error it is calling /api/auth/providers so is it correct ? Isn't there anything like it should have been */providers/credentials or anything
@Pradip Chaudhary I have done it correctly but I look at it once again though
But I wanted to ask one thing.
In the error it is calling /api/auth/providers so is it correct ? Isn't there anything like it should have been */providers/credentials or anything
It will first do a request to
/api/auth/providers
and then /api/auth/callback/credentials
Okay thanks
I am not with my computer right now so I will check it thoroughly once I get hold of it
Thanks again 😊
Thanks again 😊
Hey
I checked the NEXTAUTH_URL and it's even accessible in my website like I can console log it
I checked the NEXTAUTH_URL and it's even accessible in my website like I can console log it
import { NextAuthOptions } from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials";
const authOptions: NextAuthOptions = {
session: {
strategy: "jwt",
maxAge: 30 * 24 * 60 * 60
},
providers: [
CredentialsProvider({
name: "Credentials",
credentials: {
username: {
label: "username",
placeholder: "username",
type: "text"
},
password: {
label: "password",
placeholder: "****",
type: "password"
}
},
async authorize(credentials, req) {
const { username, password } = credentials as {
username: string;
password: string;
};
if (
username !== process.env.USERNAME ||
password !== process.env.PASSWORD
) {
throw new Error("Invalid username or password");
}
return { id: "something" };
}
})
],
pages: {
signIn: "/admin/login"
}
};
export default authOptions;
Can you check if my authoptions are correct
please don't crosspost/repost. you may bump this question (at most once a day) if you want it to get more attention. i'll delete the other post
btw how can I bump the question?
just send any messages in the question, it will bump the question to the top of the forum channel
someone please help with this
Orinoco Crocodile
Honestly there are a lot of issues with NextAuth. Im just starting with it so not sure if Next13 has broken a bit. But been getting quite frustrated myself. Most likely just using Clerk for Auth instead until this becomes more stable. Im having redirect issues and middleware redirecting back to login when authenticated
Can I use the clerk with my own designed web page