Authentication Routes

Comprehensive guide to the API routes powering your authentication system.

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.

Authentication API Routes

Register User

/api/auth/register - POST

Creates a new user account.

{
  "email": "[email protected]",
  "name": "John Doe",
  "password": "securepassword"
}

2. Login with email and password

server/api/auth/login-with-password.post.js - POST

Logs in a user with email and password

{
  "email": "[email protected]",
  "password": "securepassword"
}

3. Login with one time password

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": "[email protected]"
}

4. Verify OTP

server/api/auth/verify-otp.post.js - POST

Verifies the one time password

{
  "email": "[email protected]",
  "code": "123456", // The OTP provided to the user
  "type": "LOGIN" // Can be "LOGIN", "SIGNUP", or "FORGOT_PASSWORD"
}

5. Verify email token

server/api/auth/verify-email-token.get.js - GET

Verifies the email token

{
  "token": "email-verification-token"
}

6. Reset password

server/api/auth/reset-password.post.js - POST

Sends a reset password email

{
  "email": "[email protected]"
}

7. Reset password

server/api/auth/reset-password.patch.js - PATCH

Verifies the reset password token and sets a new password

{
  "code": "reset-token-value",
  "password": "newsecurepassword"
}

8. Resent OTP

server/api/auth/resend-otp.post.js - POST

Resends the one time password

{
  "email": "[email protected]"
}