So i have a SPA where the base path has to redirect to a locale folder. Normally i would do this by defining two paths that are pointing to the same page in the router:
routes: [
{
path: '/',
redirect: { name: 'index' }
},
{
path: '/en/',
name: 'index',
component: index
}
]
E.g. http://test.com/
is redirected to http://test.com/en
.
Following solved the issue, but i am not sure if this is best-practice?
<script>
export default {
fetch ({ params, redirect }) {
redirect(301, '/en')
}
}
</script>
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1656">#c1656</a>)</em></sub></div>