rd
rd
Explore posts from servers
NNuxt
Created by rd on 7/5/2024 in #❓・help
Passing data from module hook to plugin
I have a module and need to resolve some data in the build:manifest hook, namely some resource information (name and file). I then need to access this data in a server plugin in the app:rendered hook, so I can alter some ssrContext head entries. Normally I would pass this data via the runtimeConfig, but I can't in this instance because addPlugin is called before the first hook has executed, and any config that plugin has access to will have already been resolved. Does anyone know how I can approach/resolve this? Thanks!
1 replies
NNuxt
Created by rd on 7/31/2023 in #❓・help
Client side error handling
I'm having trouble handling errors on the client side of an SSR app. They seem to handle fine on the server. In my setup of my "product" page I have the following:
if (!product) {
throw createError({ statusCode: 404, statusMessage: 'Product not found' });
}
if (!product) {
throw createError({ statusCode: 404, statusMessage: 'Product not found' });
}
So if I navigate to the URL /shop/some-product-that-doesnt-exist as the initial server rendered route and product above is false, the server handles the error and Nuxt correctly shows my ~/error.vue component. However if I click on a <NuxtLink> to the same location on the client side, nothing happens, error.vue is not rendered, and the console shows:
Uncaught (in promise) Error: Product not found
Uncaught (in promise) Error: Product not found
I've read the error handling docs several times but can't work out what I'm doing wrong, any ideas? Thanks!
2 replies