nuxt-password-protect
nuxt-password-protect copied to clipboard
Compatible with Nuxt 3?
I know this repo isn't actively maintained anymore so this is a bit of a long shot, but if anyone has been able to get this working with Nuxt 3 and has some tips I would be eternally grateful. I'm not sure if this module simply isn't compatible anymore or I'm doing something wrong with the syntax.
So in nuxt.config.js
:
export default defineNuxtConfig({
modules: ['nuxt-password-protect'],
passwordProtect: {
enabled: true,
formPath: '/password',
password: 'hello-world',
tokenSeed: 101010,
queryString: '_pw',
cookieName: '_password',
cookie: {
prefix: '',
expires: 5
},
ignoredPaths: ['/public-page']
}
})
And package.json
:
{
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"dependencies": {
"nuxt": "^3.2.3",
"nuxt-password-protect": "^1.3.1"
}
}
index.vue
<template>
//some stuff
</template>
<script>
export default{
middleware: ['password-protect']
}
</script>
Gives the error:
ERROR Cannot start nuxt: Cannot read properties of undefined (reading 'password-protect')
at featureToggleModule (~node_modules\nuxt-password-protect\lib\module.js:5:20)
at installModule (~/node_modules/@nuxt/kit/dist/index.mjs:435:21)
at async initNuxt (~/node_modules/nuxt/dist/index.mjs:2256:7)
at async load (~/node_modules/nuxi/dist/chunks/dev.mjs:6810:9)
at async Object.invoke (~/node_modules/nuxi/dist/chunks/dev.mjs:6871:5)
at async _main (~/node_modules/nuxi/dist/cli.mjs:50:20)
Again, any help is appreciated.
Since its not actively maintained. Does anyone know an alternative?