universal-vue / uvue

Vue CLI plugin to create universal Vue applications with ease
https://universal-vue.github.io/docs/
MIT License
127 stars 13 forks source link

(client) Redirect whole page if passed a complete URL #64

Closed davidyuk closed 11 months ago

davidyuk commented 3 years ago

What kind of change does this PR introduce?

It fixes redirection by URL on the client-side.

What is the current behavior?

this.$redirect('http://example.com'); works fine in SSR, but if it is called on the client-side then the URL passed to VueRouter that will try to resolve it in registered routes.

What is the new behavior?

If $redirect argument is a complete URL (has protocol and host, URL won't fail parsing it) then the browser window would be completely redirected to that URL otherwise it would try to resolve it using VueRouter as before.

Checklist:

I think the proposed behavior is already intended by current documentation.

It is tricky to test because it is needed an external service or a separately hosted page. Can we redirect to example.com or so?