Home

Issue: 770

Allow redirect to absolute URL

[issue link]

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

This feature request is available on Nuxt.js community (#c661)