LVDM
LVDM

Reputation: 454

Nuxt generate, status 500

I have a nuxt app that get it's data from a Wordpress rest api, when you run nuxt generate i have about a 100 pages generated simultaneously. Now like 80% of these api calls made while generating fail with a status 500.

enter image description here

However if i visit this URL in development mode it works perfectly, and sometimes it actually gets generated (it's kind of random). So i'm thinking it's because of the massive amount of request.

Now i've tested this also in the front-end and did 500 requests simultaneously and this doesn't fail. So first i taught it is a memory issue in the backend but i'm not sure why i don't have the same problem in the front-end.

Any ideas?

Upvotes: 0

Views: 540

Answers (2)

David Carignan
David Carignan

Reputation: 46

I am a bit late but this might help future people from Google as this thread came up pretty high.

WordPress does not seem to like receiving multiple requests, especially if your site contains multiple pages. Adding the interval property in your nuxt.config.js (as pointed out by Hermann Dettmann) will space out the generation of each page.

It usually fix this issue for me. The task will take more time to execute, but at least it won't blow up.

export default {
  mode: 'universal',
  generate: {
    interval: 1000,
    /* ... */
  }
  /* ... */
}

Upvotes: 0

Hermann Dettmann
Hermann Dettmann

Reputation: 240

I had the same issue and could track this down to two problems:

  1. process.env.NODE_ENV was always on 'production' so not the local but the live API was used for some API calls.
  2. I didn't set the interval property. But when I added it with a value of 500 then npm run generate was working again.

Maybe this helps.

Upvotes: 1

Related Questions