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

redirects not working #58

Closed phil294 closed 3 years ago

phil294 commented 3 years ago

Describe the bug The redirect helper does not redirect to the desired target but instead redirects to the current page, resulting in ERR_TOO_MANY_REDIRECTS on Chrome.

To Reproduce As per docs:

async asyncData({ redirect }) {
      return redirect({ to: '/vuex' }, 302);
}

Results in these response headers:

Connection: keep-alive
Date: Sun, 03 Jan 2021 12:36:52 GMT
Keep-Alive: timeout=5
Location: /async-data
Transfer-Encoding: chunked

Expected behavior In this example, the response header

Location: /vuex

Tested with the latest uvue/examples repository.

Please indicate versions of:

node: 12.20
vue-cli: 
uvue: 0.1.7
os: manjaro linux
browser: chromium
yabab-dev commented 3 years ago

Hi! First, thanks for your time and reporting this!

Unfortunately I cannot reproduce your issue, I tested on vanilla project and with examples repository. Headers are okay:

HTTP/1.1 302 Found
Location: /about
Date: Sun, 03 Jan 2021 21:18:18 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked

Can you provide a reproduction code ?

phil294 commented 3 years ago

Unfortunately I cannot reproduce your issue

huh that is weird. Check out this repro / file / line: https://github.com/phil294/examples/blob/redirect-bug-demo/src/views/AsyncData.vue#L20 Run this very branch, open /async-data, refresh the site and you should see the problem. Tested on FF + Chrome.

Thanks once again for this awesome project!

yabab-dev commented 3 years ago

Oh I did not see, I made a mistake in docs, it's not to but path:

redirect({ path: '/vuex' }, 302);
phil294 commented 3 years ago

ok that works great, thank you