Holy De Mello
Holy De Mello
NNuxt
Created by Holy De Mello on 9/1/2024 in #❓・help
Nuxt 3 Middleware issue
middleware/auth.js
export default defineNuxtRouteMiddleware((to,from)=>{
const cookie = useCookie('__session')
if(!cookie.value){
console.log("cookie.value is none")
return navigateTo('/admin/login')
}
console.log('Cookie found:', cookie.value)
})
export default defineNuxtRouteMiddleware((to,from)=>{
const cookie = useCookie('__session')
if(!cookie.value){
console.log("cookie.value is none")
return navigateTo('/admin/login')
}
console.log('Cookie found:', cookie.value)
})
Dashboard.vue
<template>
<h1>Dashboard</h1>

</template>

<script setup>
definePageMeta({
middleware: ['auth'],
})
</script>
<template>
<h1>Dashboard</h1>

</template>

<script setup>
definePageMeta({
middleware: ['auth'],
})
</script>
- Navigate to is getting fired regardless if cookie value exist or not - When cookie value exists it doesn't do console.log("cookie.value is none") still navigate to works - I tried opening the dashboard from different url, it lands to /admin/login
4 replies
NNuxt
Created by Holy De Mello on 8/30/2024 in #❓・help
Trying to use Leaderline with Nuxt App
https://www.npmjs.com/package/leader-line-vue - downloaded this package using npm and tried to import it
https://www.npmjs.com/package/leader-line-vue - downloaded this package using npm and tried to import it
Component.vue
import LeaderLine from 'leader-line-vue';
import LeaderLine from 'leader-line-vue';
I am getting below error
Cannot read properties of undefined (reading 'documentElement')
Cannot read properties of undefined (reading 'documentElement')
I am trying to figure out how to fix this.
6 replies