Static GitHub Issues

[3002] Redirect absolute url in middleware

prev: 'Redirecting to external page.' on error
next: Duplicated behavior in socket example

I'm having a problem when redirecting to an absolute URL inside a middleware, it return to a page with ERR_REDIRECT and then go to the desired page.

Nuxt mode: spa

auth.js middleware:

export default function (context) {
  const token = window.localStorage.getItem('token')
  if (!token) {
    context.redirect('https://nuxtjs.org/')
  }
}

Video showing the page: middleware nuxt

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c2601">#c2601</a>)</em></sub></div>