nuxt-community / redirect-module

No more cumbersome redirects for Nuxt 2!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nuxt 3 Support

harlan-zw opened this issue Β· comments

Hey πŸ‘‹ It looks like this module hasn't been updated for Nuxt 3. In an effort to improve the developer experience of modules, I've updated the module to clarify that it only supports Nuxt 2.

Alternatives:

  • In Nuxt 3 redirects are supported out of the box through Route Rules, this module may not be needed.
export default defineNuxtConfig({
  routeRules: {
   // Redirects legacy urls
    '/old-page': { redirect: '/new-page' }
  }
})

@manniL I'm presuming it's safe to say this can be deprecated at some point, given #120

Yes, absolutely πŸ‘

This package enabled us to pull the redirect data from CMS and use it in runtime by using its middleware.
i think this is not possible with routeRules config from nuxt 3. Thats why i had to create my own local module for my use case.
Do you advise me to contribute to this repo to make it compatible with nuxt 3, or create another public module?

@ersah123 You can still use a nitro servermiddleware and pull things in there (+store them). ☺️
Not necessarily needs a module

but nitro middleware is a runtime and it runs on every server request, right? So where can i pull the redirect data in build time and share with nitro middleware?

you can pull them on the first request (or during prerendering), then store them via unstorage (useStorage) and access them πŸ‘

But then my initial page load speed will suffer since it is like 11k lines of redirect rules i have :(
I really prefer to get them on build time

Only the first one, and as I said, you could still "warm up" that cache ☺️

But then my initial page load speed will suffer since it is like 11k lines of redirect rules i have :( I really prefer to get them on build time

You should use CloudFlare bulk redirects or something with so many

But then my initial page load speed will suffer since it is like 11k lines of redirect rules i have :( I really prefer to get them on build time

You should use CloudFlare bulk redirects or something with so many

That's true. we will implement long term solution later since we are trying to do nuxt 2 - bridge - nuxt 3 migration right now.
Thanks for the suggestion :)

@manniL , to update you and this topic, i have found a another solution for my use case which i believe was better as a short term solution.
Im now using nitro plugin (defineNitroPlugin) to pull data redirect data on nitro initialisation and adding that data to nitroApp's event object as new key so that it is available in every request on runtime in middleware (defineEventHandler).
There i check if the event is 404, then i run my redirect checks.