#Migration from trailingSlash: true

4 messages · Page 1 of 1 (latest)

minor stump
#

How to get the equivalent of trailingSlash: true from Nuxt2?
I'm trying with:

export default defineNuxtConfig({

  target: 'static',
  ssr: 'true',

  router: {
    options: {
      strict: true
    }
  }
})

But is not working.

#

I also added a global middleware:

export default defineNuxtRouteMiddleware((to, from) => {
  const { path, query, hash } = from
  if (!path.endsWith('/')) {
    const newPath = `${path}/`
    return navigateTo({ path: newPath, query, hash }, {
      redirectCode: 301
    })
  }
})

But nothing changes.

#

Actually if I browse to http://localhost:3000/foo/ I get the server reloading forever with Status Code 503 Server Unavailable
If I browse to http://localhost:3000/foo I get

{
"statusCode": 404,
"statusMessage": "Cannot find any route matching /foo.",
"stack": []
}             

What the hell is this? 😩 Is tralingSlash somehow supported?

#

pages/foo.vue is pretty simple:

<template>
  <NuxtLink to="/bar">Bar</NuxtLink>
</template>

<script setup>
definePageMeta({
  title: 'Foo',
  description: 'Description of foo'
})
</script>