nuxt-community / redirect-module

No more cumbersome redirects for Nuxt 2!
MIT License
312 stars 17 forks source link

Leverage vue-router alias/redirect #3

Closed manniL closed 1 month ago

manniL commented 6 years ago

Currently, the module only works in universal mode, because a server middleware is used. A possible solution to make the module work in SPA and generate mode would be the alias/redirect options in the vue-router.

Related: #1 Read more

juno-yu commented 6 years ago

looked into this a little bit

Ignoring this, I have made an implementation based on 'addplugin call in module' approach for a simple path that works in both matching merchanism (a redirect from /abc -> /about) https://codesandbox.io/s/qkxvnmv104

In spa mode the redirection looks working as expected for dev / generated mode, including generating the page for '/abc' by adding it into options.generate.routes

In universal generate mode i encountered a blocker, that the redirection logic by server middleware seems not to be considered so '/abc' is unable to be resolved and generated finally (while in universal dev mode both 1)a direct visit to '/abc' 2)clicking a router-link for '/abc' work as expected)

manniL commented 6 years ago

@juno-yu Thanks for the research!

I'd appreciate having spa redirect support in the module.

For generate you are right, the serverMiddleware isn't considered at all. Could we apply the idea from the spa version there and leverage the spa fallback mechanism of generate?

manniL commented 1 month ago

Closing, as the module will remain in maintenance only.