I have QR codes, that exist on many products. Now link from QR is not actually. I need redirect old link to new external one.
I use Nuxt 2 and Vue 2.
I try do that:
1) // nuxt.config.js
routeRules: {
'/api/images/image.pdf': { redirect: 'https://example.com' },
},
2) //middleware/redirect.global.js
export default defineNuxtRouteMiddleware((to, from) => {
if (to.path === '/api/images/image.pdf') {
return navigateTo('//example.com', { redirectCode: 301 })
}
})
Both of them do not work. How can I implement redirect from QR link to external link using Nuxt 2?