title: Vue SSR serverPrefetch server redirect with this.$ssrContext.res.redirect
body: <p>Is it possible to do a redirect from a component, in VUE SSR, without getting the error on the server console: <code>[ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client</code>?</p>
  
  <p>Code is as follows:</p>
  
  <pre><code>serverPrefetch() {
      // need the data from this.fetchPage service to decide on the redirect
      return this.fetchPage().then(function (response) {
          // do some checks here
  
          // THIS IS THE NODE EXPRESS REDIRECT
          this.$ssrContext.res.redirect('/');
          this.$ssrContext.res.end(); // with or without, same error
      }.bind(this));
  },
  beforeMount() {
      this.fetchPage();
  }
  </code></pre>
  
  <p>NOTE: If I try to use <code>this.$router.replace('/')</code> (or any other methods), I get the error: <code>[Vue warn]: Error in callback for watcher $route: ReferenceError: document is not defined</code>.</p>
  
  <p>In my project I did the redirect on the client side, but I was wondering if this can be done also from server.</p>