Open sneko opened 2 years ago
Here was my hacky solution that didn't require changing the main libs:
in vue.config.js:
module.exports = {
pluginOptions: {
ssr: {
onRender(res, context){
if(context._routeRedirect){
res.redirect(301, context._routeRedirect); // do the redirect
const send = res.send; // store local reference to original send method
// override send method to prevent headers from being sent
res.send = function(){
res.send = send; // restore the original send method for subsequent calls
}
}
},
... other configs
}
}
}
Hi,
It's to fix this issue when doing HTTP redirections:
It was not critical in the past (had this 2 years ago https://github.com/Akryum/vue-cli-plugin-ssr/issues/144#issuecomment-601103458), it was just logging things into the console. But since I upgraded some Vue dependencies the "simple log" is now something making the server crashes.
Note: my previous version of
vue-server-renderer
wasv2.6.11
and I tried upgrading tov2.6.14
. Don't know which change exactly breaks things... but it's fine with this PR 😄So to avoid being stuck in a previous version I did a little trick to always respect values that could be passed to the
res
object.Hope this helps even if the repo is no longer maintained.
In the meantime if you want to you it you can use a specific branch with some patches I made:
👍