Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
Nuxtjs - How to redirect an old url to an external url

I have qr codes that have been published with an old url. I need to redirect that old url to a new external url. I have just revamped this project by incorporating Nuxtjs. I have tried using the redirect middleware, but no success. Can somebody help me?

I want my old url, 'example.io/guestbooklet/1' to redirect to 'https://dashboard.example.io/guestbooklet/1'

middleware/redirects.js

export default function(req, res, next) {
    const redirects = [
      {
        from: "/guestbooklet/:property_id", 
        to: "https://dashboard.example.io/guestbooklet/:property_id"
      }
    ]
    const redirect = redirects.find((r) => r.from === req.url)
    console.log('Redirecting', redirect)
    if (redirect) {
      res.writeHead(301, { Location: redirect.to })
      res.end()
    } else {
      next()
    }
  }

nuxt.config.js

serverMiddleware: [
        '~/middleware/redirects.js'
  ],
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!