Created
July 23, 2021 16:30
-
-
Save hellerbenjamin/081c2282215d9e25213e3466df543e3a to your computer and use it in GitHub Desktop.
Nuxt add middleware from module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path') | |
export default function plugins(_moduleOptions) { | |
this.nuxt.hook('build:templates', ({ templateVars }) => { | |
templateVars.middleware.push({ | |
name: 'authenticated', | |
src: path.resolve(__dirname, 'middleware/authenticated.js'), | |
fileName: path.join('authenticated.js'), | |
options: Object.assign({}, this.options.packageName) | |
}) | |
templateVars.router.middleware.push('authenticated') | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment