This section provides a detailed breakdown of the API routes responsible for handling user authentication within your Nuxt 3 app. These routes are designed to be flexible and easy to integrate with your frontend application.
/api/auth/register - POST
Creates a new user account.
{
"email": "user@example.com",
"name": "John Doe",
"password": "securepassword"
}
server/api/auth/login-with-password.post.js - POST
Logs in a user with email and password
{
"email": "user@example.com",
"password": "securepassword"
}
server/api/auth/login-with-otp.post.js - POST
Logs in a user with one time password. This is also used for magic links.
{
"email": "user@example.com"
}
server/api/auth/verify-otp.post.js - POST
Verifies the one time password
{
"email": "user@example.com",
"code": "123456", // The OTP provided to the user
"type": "LOGIN" // Can be "LOGIN", "SIGNUP", or "FORGOT_PASSWORD"
}
server/api/auth/verify-email-token.get.js - GET
Verifies the email token
{
"token": "email-verification-token"
}
server/api/auth/reset-password.post.js - POST
Sends a reset password email
{
"email": "user@example.com"
}
server/api/auth/reset-password.patch.js - PATCH
Verifies the reset password token and sets a new password
{
"code": "reset-token-value",
"password": "newsecurepassword"
}
server/api/auth/resend-otp.post.js - POST
Resends the one time password
{
"email": "user@example.com"
}