N
Nuxt5mo ago
Wicker

In ssr and target = static is it possible to catch a 404 error before it happens?

Hello people, for context i have a static generate sites with ssr enabled also i have an error.vue in the root of the project, Sadly the site is uploaded using nginx and i cannot change the config, if a user navigates to a link which doesnt exists for example /derp, could it be possible to catch the error before it happens and redirect him to the /error page instead of nginx error page? At the moment i tried using hooks in the config
hooks: {
"pages:extend"(pages) {
pages.push({
name: "error",
path: "*",
file: resolve(__dirname, "pages/error.vue"),
});
},
},
hooks: {
"pages:extend"(pages) {
pages.push({
name: "error",
path: "*",
file: resolve(__dirname, "pages/error.vue"),
});
},
},
Which makes the prerenderer fail ( Error: [500] ) Tried using the error handler plugin
nuxtApp.hook("link:prefetch", (event) => {
if (event.includes("/asd")) navigateTo("/");
console.log("link", event);
});

nuxtApp.hook("app:error", (error) => {
navigateTo("/error");
});
nuxtApp.hook("link:prefetch", (event) => {
if (event.includes("/asd")) navigateTo("/");
console.log("link", event);
});

nuxtApp.hook("app:error", (error) => {
navigateTo("/error");
});
And ye... Is it possible to do something like that?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server