redirect default '/' to a specific path nuxt / netlify

Viewed 1944

Basically I want the root route '/' to be redirected to my '/home' route.

My Nuxt app is hosted on Netlify so I tried to do this is the _redirects file

/ /home

as per their redirect docs - but it's not working.

Now I know that in Vue in the router config you can set up redirects, but how do I achieve the same thing in Nuxt??

any help would be appreciated!

1 Answers

In your main index.vue page you would add:

<script>
  export default {
    middleware: 'redirect'
  }
</script>

Then you would create a middleware to actually redirect to desired page, in middleware > redirect.js:

export default function ({ store, redirect }) {
  return redirect('/home')
}
Related