Nuxtjs exceeds maximum call stack size in development mode and get server error 500 in production instead of my custom error page when an invalid URL is entered
P粉872101673
P粉872101673 2023-09-01 14:33:51
0
1
462

When I enter a URL that does not exist, I sometimes get a custom error and most of the time a server error (image)

This is my error.vue page:

  

Note: 1- trrrrr is just a random string I wrote in the URL to demonstrate a non-existent URL 2- In development mode, sometimes I get a custom 404 error, most of the time I get a Maximum call stack size returned error (picture)

My PWA configuration:

pwa: { meta: { title: "example", author: "example", }, icon: { purpose: "any" }, manifest: { display: "standalone", name: "example", lang: "en", useWebmanifestExtension: true, theme_color: "#01bac6", }, },

My questions are: 1-Why does my custom error page always not work?

2- Why is the code error 500 when it should be 404 because I'm on a page that doesn't exist?

P粉872101673
P粉872101673

reply all (1)
P粉345302753

Finally I found the source of the problem, this is how I caught the error when the request was not fulfilled

How the problem occurs:

asyncData(context) { return context.app.$api.fetchSinglePage(context.params.slug) .then(response => { return { page: response.content } }) .catch(e => context.error(e)) //This line causes the problem }

Change it to:

asyncData(context) { return context.app.$api.fetchSinglePage(context.params.slug) .then(response => { return { page: response.content } }) .catch(e =>{ context.error({ statusCode: 404 }) //this is how I solved it }) },

Source:https://github.com/nuxt/nuxt .js/issues/6294#issuecomment-526902792

I still don’t know why this problem occurs

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!