0👍
The behavior you’re describing seems unusual and might be caused by a combination of configurations or other plugins affecting the routes. However, here’s a way you can handle trailing slashes using a middleware:
add a middleware/remove-trailing-slash.js
:
export default function({ route, redirect }) {
if (route.path !== '/' && route.path.endsWith('/')) {
let newPath = route.path.slice(0, -1);
redirect(301, newPath);
}
}
This checks if the path ends with a slash and redirects to the same path without it.
Then, all you have to do is to register it in nuxt.config.js
:
export default {
router: {
middleware: ['remove-trailing-slash']
}
}
Hope this helps!
- [Vuejs]-Reference an external JavaScript file using Vue.js
- [Vuejs]-How to call a method every single time the field loses focus in vue.js
Source:stackexchange.com