Cannot POST /api/auth/callback/credentials
See original GitHub issueYour question Cannot POST /api/auth/callback/credentials
What are you trying to do Whenever I try to log in, I get the post error.
Feedback Documentation refers to searching through online documentation, code comments and issue history. The example project refers to next-auth-example.
- Found the documentation helpful
- Found documentation but was incomplete
- Could not find relevant documentation
- Found the example project helpful
- Did not find the example project helpful
<form method='post' action='/api/auth/callback/credentials' className="account-form">
For example, when I try to get the csrf token, it works fine.
NextAuth config:
const options = {
site: 'http://localhost:3000/api/auth',
providers: [
Providers.Credentials({
name: 'Credentials',
credentials: {
username: { label: "Username", type: "text", placeholder: "" },
password: { label: "Password", type: "password" }
},
authorize: async (credentials) => {
const user = { id: 1, name: 'J Smith', email: 'jsmith@example.com' }
if (user) {
return Promise.resolve(user)
} else {
return Promise.resolve(null)
}
}
})
],
callbacks: {
signIn: async (user, account, profile) => {
return Promise.resolve(true)
},
session: async (session, user) => {
session.foo = 'bar' // Add property to session
return Promise.resolve(session)
},
credentials: async( user,acount,profile) => {
return Promise.resolve(true)
},
redirect: async (url, baseUrl) => {
return url.startsWith(baseUrl)
? Promise.resolve(url)
: Promise.resolve(baseUrl)
}
},
session: {
jwt: true,
},
jwt: {
secret: "secret",
encryption: true
},
database: {
type: 'mysql',
host: process.env.DB_HOST,
port: 3306,
username: process.env.DB_USER,
password: process.env.DB_PASS,
database: process.env.DB_TABLE
},
debug: true,
}
I tried everything, and also the documentation doesn’t help since I can’t find what I’m looking for particularly.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:13 (2 by maintainers)
Top Results From Across the Web
Next-Auth signIn with Credentials is not working in NextJS
The issue I'm facing goes like this: I want to Login to my Next.js app using Email & Password submitted to my API...
Read more >Callbacks | NextAuth.js
This callback is called whenever a JSON Web Token is created (i.e. at sign in) or updated (i.e whenever a session is accessed...
Read more >error: callback for provider type credentials not supported
Error: HTTP POST is not supported for /api/auth/callback/credentials. Using Credentials Sign in provider. Open side panel.
Read more >Sign In With Google JavaScript API reference | Authentication
callback, The JavaScript function that handles ID tokens. ... The ID token credential response is posted to your login endpoint when a user...
Read more >Cannot GET /auth/google/callback | PassportJs - Reddit
initialize()); app.use(passport.session()); app.use(cors({ origin: "http://localhost:3000", methods: "GET,POST,PUT,DELETE", credentials: true,}) ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I was having the same issue, but I found a solution today. Here are the general steps I took:
idproperty to the Credential providersignInin my form instead ofactionandmethodExample
pages/api/[...nextAuth].jsThen in
pages/login.js:I’m using a custom express server with next-auth. It works now.
1. add route for post method and hand it to next.js
2. set jwt: true
3. set bodyParser: false
because I already use bodyParser on express.