N
Nuxt8mo ago
naithein

routes

Hi guys. Super new to nuxt. I've got the following route appearing when I console.log(router.options.routes), but all attempts to navigate it return me to the default "/" page. Also noticing that the
{
"name": "news",
"path": "/news",
"meta": {},
"alias": []
}
{
"name": "news",
"path": "/news",
"meta": {},
"alias": []
}
index.vue:
<template>
<Carousel @navigate="navigate"> </Carousel>
</template>
<script setup>

const navigate = () => {
return navigateTo({ path: '/news' });
};
</script>
<template>
<Carousel @navigate="navigate"> </Carousel>
</template>
<script setup>

const navigate = () => {
return navigateTo({ path: '/news' });
};
</script>
news.vue
<template>
<div>placeholder page</div>
</template>
<template>
<div>placeholder page</div>
</template>
Been reading https://nuxt.com/docs/getting-started/routing and i can't seem to find what I'm missing. Can anyone point me in the right direction?
Nuxt
Routing · Get Started with Nuxt
Nuxt file-system routing creates a route for every file in the pages/ directory.
7 Replies
Luckystriike
Luckystriike8mo ago
You have the nuxtpage element in your app.vue? https://nuxt.com/docs/api/components/nuxt-page
Nuxt
· Nuxt Components
The component is required to display pages located in the pages/ directory.
Luckystriike
Luckystriike8mo ago
And maybe you’ll need to await the navigateTo function without return.
No description
naithein
naitheinOP8mo ago
Yep, here's my app.vue
<template>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</template>
<template>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</template>
Awaiting the navigateTo , and even navigating to the url ie localhost:3000/news is still showing the index page 😕
Luckystriike
Luckystriike8mo ago
Just to make sure, you page is in the pages folder? Share your navigate function
naithein
naitheinOP8mo ago
Okay, I actually figured it out. I'm using a supabase extension and I had to explicitly tell it not to redirect after making a request.
supabase: {
key: process.env.SUPABASE_KEY,
url: process.env.SUPABASE_URL,
redirect: false <--- this line right here. not sure why it isn't set that way by default
}
supabase: {
key: process.env.SUPABASE_KEY,
url: process.env.SUPABASE_URL,
redirect: false <--- this line right here. not sure why it isn't set that way by default
}
Appreciate your time!
Luckystriike
Luckystriike8mo ago
Ow damn hahah Cool nice you found the issue
naithein
naitheinOP8mo ago
🙇🏻
Want results from more Discord servers?
Add your server