E♭
E♭
NNuxt
Created by E♭ on 7/23/2024 in #❓・help
Unknown route middleware.
I have this middleware:
export default defineNuxtRouteMiddleware((to, from) => {
const { user } = useAuth();

if ( ! user) {
return navigateTo('/login');
}
})
export default defineNuxtRouteMiddleware((to, from) => {
const { user } = useAuth();

if ( ! user) {
return navigateTo('/login');
}
})
And I have this page:
<template>
<div>
<p>Authenticated users only!</p>
</div>
</template>

<script setup lang="ts">
definePageMeta({
middleware: ["auth"]
})
</script>
<template>
<div>
<p>Authenticated users only!</p>
</div>
</template>

<script setup lang="ts">
definePageMeta({
middleware: ["auth"]
})
</script>
And I receive the following error:
500 Unknown route middleware: 'abc'. Valid middleware: .
2 replies
NNuxt
Created by E♭ on 7/21/2024 in #❓・help
Extracting component(s) into a library
Is there some kind of "template" I can use to create a component library? Well, not so much a library - I want to extract a single component from my app and make it so that myself and others can quickly and easily import it into any other projects, as and when needed. The thing I 'm unsure about is that there are various other files that the component depends on, such as some library/util files and a bunch of audio files and such. I need to know how to package all this stuff up together. I did find this thing but it doesn't mention how to include assets such as images, audio etc. - https://cli.vuejs.org/guide/build-targets.html#library I also ran across this while searching - https://github.com/laynezh/vite-plugin-lib-assets But I'm not really sure if this does what I need, and/or if there is some other/better way. Thank you!
1 replies