http-redirectvuejs3nuxt.jshttp-status-code-404nuxt3.js

Nuxt.js localhost redirects to /login automatically, resulting in 404 error


I created a new Nuxt project and want to use the pages/ directory, therefore I deleted app.vue as it is no longer needed. The /pages directory until now only contains the index.vue file with the minimal required content:

<template>
 <div></div>
</template>

<script setup>
useHead({
    title: '',
    meta: [
        { name: 'description', content: '' },
    ],
});


</script>

<style scoped>

</style>

When starting the development server via nuxt's cli command npm run dev on the default port localhost:3000, the page automatically redirects to localhost:3000/login, which results in an error 404 as login.vue does not exist in the pages directory. Deleting the /login part of the url does not work, it jumps back.

There is no middleware in use and also the nuxt config file contains nothing explaining said behaviour:

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  devtools: { enabled: true },
  modules: ['@nuxtjs/tailwindcss', '@nuxtjs/supabase'],
  app: {
    head: {
      title: '',
      meta: [{ name: 'description', content: '' }],
    },
  },
});

There is also nothing going on either in the /server directory which would lead to the described error, nor am I using any authentication methods.

I tried to add the login.vue file in the pages directory with/without the same content as the index.vue file, but that changed nothing. It still only shows the 404 page, saying "404 Page not found: /login" (which obv. does not exist). This seems to be the case in different nuxt versions, starting from at least @3.11.2.

Does anyone know this strange redirecting behaviour when not even using any obvious redirects?


Solution

  • The issue here comes from the Supabase module - by default, it redirects to login.
    As per docs:

    Redirect automatically to the configured login page if a non authenticated user is trying to access a guarded. You can disable all redirects by setting this option to false.