-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server redirect implementation #144
Comments
Hi @ruslansp , did you find how to do that? Thank you, |
@Akryum maybe you have an idea on this? I saw multiple issues about that Here is an example: https://stackoverflow.com/a/57925996/11314316 could be great to be able overriding all your error catching logic. We could like that custom if we send html or not depending on httpCode (applied only for redirections 301/302?) Thank you, |
Hi. In version v0.6.0 added extendContext parameter in config. You can add respose to context and continue to use res for redirect. Not sure, but it seems you can solve it this way. |
Hi @ruslansp , If you look at Lines 112 to 162 in ea4aeef
Line 160 in ea4aeef
So even if I use
|
Does #225 help with this? It's allowed me to do something like: In app set a variable like entry-server.js context.rendered = () => {
// ...
context._routeRedirect = app._routeRedirect || null
} then in vue.config.js For 404s I was just setting extendContext = (req, res, process) => {
const extension = {}
if (req.path === '/404') {
extension.httpCode = 404
}
return extension
} For redirects based on a vue instance condition, changing the response's status late, to not match context.httpCode will stop res.send(html) from sending, stopping errors. onRender = (res, context) => {
if (context._routeRedirect) {
res.redirect(301, context._routeRedirect)
}
} |
2 years since then! And upgrading some Vue librairies makes the error To keep my own logic of redirecting within components with Hope this helps :) |
Here was my hacky solution that didn't require changing the main libs: in vue.config.js:
|
I propose to add to the settings option for error handling on the server, for example, as handleError in Hackernews or add res in the server context
At this moment I did not find the possibility to implement a redirect on the server, for example, a 302 redirect to the login page.
The text was updated successfully, but these errors were encountered: