nuxt-alt / auth

An alternative module to @nuxtjs/auth
https://nuxt-alt-auth.vercel.app/
MIT License
96 stars 20 forks source link

Middleware not work on '/' index page #56

Closed ftrsoft closed 10 months ago

ftrsoft commented 1 year ago

Environment

Nuxt Config

// https://nuxt.com/docs/api/configuration/nuxt-config

export default defineNuxtConfig({ modules: [ 'nuxt-quasar-ui', '@nuxt-alt/auth', '@nuxt-alt/http', '@pinia/nuxt', ], quasar: { iconSet: 'mdi-v7', plugins: ['Notify'], extras: { font: 'roboto-font', fontIcons: ['material-icons', 'mdi-v7'], }, }, auth: { strategies: { local: { scheme: 'refresh', localStorage: { prefix: 'auth.' }, token: { prefix: 'access_token.', property: 'results.access', maxAge: 60 5, global: true, }, refreshToken: { prefix: 'refresh_token.', property: 'results.refresh', data: 'refresh', maxAge: 60 60 24 15 }, user: { property: 'results.user', autoFetch: true }, endpoints: { login: {url: '/api/token/', method: 'post'}, refresh: {url: '/api/token/refresh/', method: 'post'}, user: {url: '/api/v1/user/', method: 'get'}, logout: {url: '/api/v1/user_logout/', method: 'post'} }, } }, globalMiddleware: true, redirect: { login: '/login', logout: '/login', callback: '/', home: '/' }, pinia: { persist: true, }, }, http: { baseURL: 'http://127.0.0.1:8000/', browserBaseURL: 'http://127.0.0.1:8000/', }, runtimeConfig: { app: { // baseURL: 'http://localhost:8000/', } } })

Reproduction

none

Describe the bug

When I use middleware at 'pages/index.vue' it is now work I have global middleware enabled and the index.vue page:

<template>
    <q-page class="row justify-center items-baseline text-center">
          <h3 class="text-3xl">Hello!</h3>
    </q-page>
</template>

<script setup>
definePageMeta({
    name: 'index',
})
</script>

<style scoped>

</style>

But when I go to http://127.0.0.1:3000/ it is displayed regardless of the authorization

Additional context

If I rename page to 'pages/index1.vue' then the path http://127.0.0.1:3000/index1 works as it should!

Logs

No response

ftrsoft commented 10 months ago

Middleware not work on "/" page