
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@zellart/nuxt-basic-auth
Advanced tools
This module provides basic auth for nuxt 3.
npm install -D @zellart/nuxt-basic-auth
You need to set username / password to be able to use basic auth:
import { defineNuxtConfig } from 'nuxt'
export default defineNuxtConfig({
modules: [
['basic-auth', {
username: 'username',
password: 'password'
}]
],
})
Type: boolean
Default: true
If set to false, skip authentication.
You might want to use that in comination with .env variables.
import { defineNuxtConfig } from 'nuxt'
export default defineNuxtConfig({
modules: [
['basic-auth', {
username: 'username',
password: 'password',
enabled: process.env.IS_PROD !== '1'
}]
],
})
Type: string[]
Default: []
Sometimes routes need to be accessible regradless of basic auth setting. One example would be health check routes that rely on a 200 response.
import { defineNuxtConfig } from 'nuxt'
export default defineNuxtConfig({
modules: [
['basic-auth', {
username: 'username',
password: 'password',
whitelistedRoutes: ['/api/health']
}]
],
})
Type: string
Default: default
In rare cases you might need to set the realm in order to group basic auth together.
import { defineNuxtConfig } from 'nuxt'
export default defineNuxtConfig({
modules: [
['basic-auth', {
username: 'username',
password: 'password',
realm: 'myAwesomeRealm'
}]
],
})
You can also use .env variables for the following Options. Just set them in your .env file / enviroment without the need to configure them in your nuxt config.
There are some alternatives to this module you might want to consider.
There is already a good solution for nuxt 2 but it is not compatible with nuxt 3. ➔ Nuxt 2 Module
➔ nuxt-basic-authentication-module
This module offers nearly the same functionality. Is uses a third party library ('basic-auth') to abstract the basic auth handling and misses the option to whitelist routes. The configuration is done on runtimeConfig and uses and uses a notation that needs getting used to. If you need to set production domains that are excluded from the basic auth this is the way to go.
This module offers the basic auth feature. Is uses a third party library ('basic-auth') to abstract the basic auth handling and lacks the option to whitelist routes. It uses nitro hooks to inject the handler which is quite bare bone. Nuxt however suggests to use the addServerHandler() function for injecting middlewares.
If you want, you can provide the same functionality with a custom server middleware.
basicAuth: {
password: 'password',
username: 'username',
realm: 'defaultRealm',
whitelistedRoutes: []
}
This module uses the
npm run dev:prepare to generate type stubs.npm run dev to start playground in development mode.FAQs
This module provides basic auth for nuxt 3.
The npm package @zellart/nuxt-basic-auth receives a total of 0 weekly downloads. As such, @zellart/nuxt-basic-auth popularity was classified as not popular.
We found that @zellart/nuxt-basic-auth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.