You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Good morning! I have a problem with NextAuth. I added the package to my Next project with the command npm install next-auth@beta and created the routes and provider for credentials. When I try to log in, I am redirected to http://localhost:3000/api/auth/error and the page appears: 404 | This page could not be found. but not even the authorize of src\app\auth\components\auth-form.tsx was called
src\app\api\auth[...nextauth]\routes.ts:
export { GET, POST } from '@/services/auth';
src\services\auth\index.ts:
I put an example user, as I will use the ldap protocol to authenticate my user's credentials
import NextAuth from 'next-auth';
import CredentialsProvider from 'next-auth/providers/credentials';
export const {
handlers: { GET, POST },
auth,
} = NextAuth({
pages: {
signIn: '/auth',
signOut: '/auth',
error: '/auth',
},
providers: [
CredentialsProvider({
name: 'ldap-auth',
credentials: {
username: { label: 'Username', type: 'text' },
password: { label: 'Password', type: 'password' },
},
async authorize(credentials, req) {
console.log(credentials);
// Temporary: If the user has the same username and password, returns the user
if (credentials.username === 'user15052' && credentials.password === '!Test!1234') {
return {
accountName: 'user15052',
name: 'Rafael Drigo',
email: '[email protected]',
memberOf: ['users-br-dev', 'fp-br-it', 'Duo-MFA-Users', 'SSLVPN-Users'],
};
}
// If the user does not have the same username and password, returns null
return null;
},
}),
],
});
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Good morning! I have a problem with NextAuth. I added the package to my Next project with the command
npm install next-auth@beta
and created the routes and provider for credentials. When I try to log in, I am redirected tohttp://localhost:3000/api/auth/error
and the page appears:404 | This page could not be found.
but not even the authorize ofsrc\app\auth\components\auth-form.tsx
was calledsrc\app\api\auth[...nextauth]\routes.ts:
src\services\auth\index.ts:
src\app\auth\components\auth-form.tsx:
Can anybody help me? I haven't implemented it yet, but I will redirect the user to "/" when he is authenticated
Beta Was this translation helpful? Give feedback.
All reactions