Static GitHub Issues

[770] Allow redirect to absolute URL

prev: Implementing D3 as client-side only package
next: HMR for the style nestedly imported

Feature request: Allow redirects to absolute URLs, SSR and client-side.

We have an app (https://domainr.com) with several legacy URLs, some of which redirect to other websites. We’re exploring using Nuxt/Vue for our new website and would like to preserve this behavior.

Snippet to reproduce

~/pages/_domain/iana.vue

<script>
export default {
  fetch ({ params, redirect }) {
    redirect(301, `https://www.iana.org/domains/root/db/${params.domain}.html`)
  }
}
</script>

Steps to reproduce

Navigate to /com/iana

Expected

Redirect to https://www.iana.org/domains/root/db/com.html

(Click here to see expected behavior: https://domainr.com/com/iana)

What actually happens

Redirect to /https:/www.iana.org/domains/root/db/com.html (local URL)

Background

Nuxt only allows local redirects to a path, which is prepended with router.base here: https://github.com/nuxt/nuxt.js/blob/dev/lib/app/server.js#L39

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