NuxtN
Nuxt11mo ago
4 replies
dan1234

NUXT server page navigateTo redirect

Hello!

I have a Nuxt page in /pages directory. Say /buy/index.server.vue
with content
<script setup lang="ts"> // Some API calls using useFetch, and then based on API calls results, redirect user to different urls //..... await navigateTo('https://google.com', { external: true }); </script>

When I goto localhost/buy url, it throws 302 Server error.

But when I remove .server from file, it works as expected i.e. I am redirected to google.
I was hoping that .server will only run this on server and redirect user accordingly.
image.png
Was this page helpful?