Akryum / vue-cli-plugin-ssr

:sparkles: Simple SSR plugin for Vue CLI
https://vue-cli-plugin-ssr.netlify.com/
MIT License
444 stars 69 forks source link

Allow late redirects in onRender #225

Closed almunnings closed 1 year ago

almunnings commented 4 years ago

Addressing issue in #144

If there is some late app-based condition met that would require an early 301 redirect, theres no way to do this without generating an error.

This just checks the status code is as expected in the res object before progressing with the send.

Can then override using (for example):

onRender = (res, context) => {
  if (context.myRedirectUrl) {
    res.redirect(302, context.myRedirectUrl)
  }
}