API handler warning
Unanswered
Brown bear posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Brown bearOP
API handler should not return a value, received object.
anyone know how to fix this, console thing?
anyone know how to fix this, console thing?
17 Replies
![Avatar](https://cdn.discordapp.com/avatars/194128415954173952/708a8637ada505b6b7a85972807d9dca.webp?size=256)
Alfonsus Ardani
return NextResponse object, not values/object
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Brown bearOP
this is my current authoptions im returning a user
CredentialsProvider({
name: "Credentials",
credentials: {
email: {
label: "Email",
type: "text",
placeholder: "jsmith@example.com",
},
password: { label: "Password", type: "password" },
},
async authorize(credentials) {
if (!credentials) return null;
signInWithEmailAndPassword(auth, credentials.email, credentials.password)
.then(userCredential => userCredential.user)
.catch(error => {
console.log(error);
null;
});
return null;
}
}),
![Avatar](https://cdn.discordapp.com/avatars/194128415954173952/708a8637ada505b6b7a85972807d9dca.webp?size=256)
Alfonsus Ardani
thats not api handler
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Brown bearOP
I dont have a api handler
do i need to define one?
![Avatar](https://cdn.discordapp.com/avatars/194128415954173952/708a8637ada505b6b7a85972807d9dca.webp?size=256)
Alfonsus Ardani
when you setup nextauth you need to create api handler...
so you must have one
either under /pages/api or /app dir
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Brown bearOP
The sessionprovider?
![Avatar](https://cdn.discordapp.com/avatars/194128415954173952/708a8637ada505b6b7a85972807d9dca.webp?size=256)
Alfonsus Ardani
![Image](https://cdn.discordapp.com/attachments/1120308084707950593/1120314600462762004/image.png)
or in
/app/auth/[...nextauth]/route.ts
file![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Brown bearOP
in my ...nextauth.js I just have my authoptions with the provider
i dont have the latter file
is it somewhere in the docs?
![Avatar](https://cdn.discordapp.com/avatars/194128415954173952/708a8637ada505b6b7a85972807d9dca.webp?size=256)
Alfonsus Ardani
no you only need one of them
so ure using the one in
pages
dir![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Brown bearOP
yup this is my full file
export const authOptions = {
// Configure one or more authentication providers
providers: [
GoogleProvider({
clientId: config.google.clientId,
clientSecret: config.google.clientSecret,
}),
CredentialsProvider({
name: "Credentials",
credentials: {
email: {
label: "Email",
type: "text",
placeholder: "jsmith@example.com",
},
password: { label: "Password", type: "password" },
},
async authorize(credentials) {
if (!credentials) return null;
signInWithEmailAndPassword(auth, credentials.email, credentials.password)
.then(userCredential => userCredential.user)
.catch(error => {
console.log(error);
null;
});
return null;
}
}),
],
};
export default NextAuth(authOptions);