Try to learn Nuxt, some wine and some water as a Swedish proverb says.
I got som problem with the error handling, when I build app (no problem in dev). Looks like it do not live so good with Apache and its htaccess file. This is my htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
The basic error handling function (error.vue in site root), for an example if I go to http://nuxtshop.localhost/xyz/zyz, it triggers. But its the error with createError function that do not trigger right, it just redirect to home and then I get a blank page (actually the default.vue layout, no slot populated). For an example I have a product page with this code, were I try to handle if the product do not exist (url, i.e. params do not exist).
Script:
<script setup>
const { id } = useRoute().params;
const runtimeConfig = useRuntimeConfig()
const uri =`${runtimeConfig.public.apiUrl}/api/content/item/Products/${id}`
const { data: product } = await useFetch(uri, {
method: "GET",
key: id,
})
if (!product.value) {
throw createError({ statusCode: 404, statusMessage: "Procuct not found
(shop id)" })
}
</script>
Via Active questions tagged javascript - Stack Overflow https://ift.tt/DpwSUNz
Comments
Post a Comment