I am generating static pages from nuxt on netlify. We have the structure of url without trailing slashes. For SSR we had trailingslash option set to false and custom redirect with redirect module. But for ‘nuxt generate’ option this is no longer working
I can’t seem to setup 301 redirects for url’s ending with trailing slash.
Eg.
https://example.com/blog - works
https://example.com/blog/ - throws 404
in nuxt.config we got
router: {
trailingSlash: false
},
redirect: [{
from: '^/(.*)/$',
to: (from, req) => {
let trailingUrl = req.url.endsWith('/') ? req.url.slice(0, -1) : req.url
return trailingUrl
},
}],
All works on local server but not on netlify. Any ideas?