Nuxt Application Build Request failed with status code 429 Error

site name: Netlify App

error: Request failed with status code 429 while deploying. For Example:
[error] getPastGames Request failed with status code 429
10:39:18 PM: at createError (node_modules/axios/lib/core/createError.js:16:15)
10:39:18 PM: at settle (node_modules/axios/lib/core/settle.js:17:12)
10:39:18 PM: at IncomingMessage.handleStreamEnd (node_modules/axios/lib/adapters/http.js:269:11)
10:39:18 PM: at IncomingMessage.emit (events.js:215:7)
10:39:18 PM: at endReadableNT (_stream_readable.js:1184:12)
10:39:18 PM: at processTicksAndRejections (internal/process/task_queues.js:80:21)

Dear community,

I spent a lot of time researching, unfortunately I can not make any progress. I am running a NUXT project hosted on Netlify. I am trying to generate dynamic routes. When deploying I always get the
429 error. I understand that there is an API overload. But for me it makes no sense where this overload comes from. Please see my nuxt.config.js. I also tried to add the intervall property with a high value of 3000. But that also doesn’t help.

import axios from 'axios';

let dynamicRoutes = () => {
  return axios.get('https://www.ubc-stp.at/wordpress/wp-json/wp/v2/news?page=1&per_page=100&_embed=1').then(res => {
  return res.data.map(news => `/newspage/${news.id}`)
  })
 }

export default {
  // Target: https://go.nuxtjs.dev/config-target
  static: true,
  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    title: 'SKN St.Pölten Basketball',
    htmlAttrs: {
      lang: 'en',
    },
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      {
        hid: 'description',
        name: 'description',
        content:
          'Webseite des Basketballvereins SKN St. Pölten Basketball. Ein Top-Team der Bet-At-Home Basketball Superliga.',
      },
      { name: 'format-detection', content: 'telephone=no' },
    ],
    link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.png' }],
  },

  // Global CSS: https://go.nuxtjs.dev/config-css
  css: ['~/assets/styles/app.scss', 'swiper/swiper.scss'],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: [
    { src: '~/plugins/aos.client', ssr: false },
    '~/plugins/data.server.js',
    '~/plugins/filter.js',
    { src: '~/plugins/vue-awesome-swiper', ssr: true },
  ],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
    // https://go.nuxtjs.dev/typescript
    '@nuxt/typescript-build',
    '@nuxtjs/google-fonts',
    [
      'nuxt-fontawesome',
      {
        component: 'fa',
        imports: [
          { set: '@fortawesome/free-brands-svg-icons', icons: ['faTiktok'] },
        ],
      },
    ],
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    // https://go.nuxtjs.dev/bootstrap
    'bootstrap-vue/nuxt',
    '@nuxtjs/axios',
    [
      'nuxt-cookie-control',
      {
        locales: ['de'],
        blockIframe: true,
        controlButton: false,
        barPosition: 'bottom-right',
        colors: {
          barBackground: '#1d314d',
        },
        text: {
          barTitle: '',
          acceptAll: 'Akzeptieren',
          barDescription:
            'Um die Website optimal gestalten und verbessern zu können, verwendet diese Website Cookies. Durch Bestätigung erklären Sie sich damit einverstanden, dass Cookies gesetzt werden.',
        },
      },
    ],
  ],
  axios: {
    baseURL: 'https://www.ubc-stp.at/wordpress',
  },
  bootstrapVue: {
    icons: true,
  },
  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
    vendor: ['aos'],
  },
  googleFonts: {
    families: {
      // a simple name
      Roboto: true,

      // a name with spaces
      'Barlow+Condensed': true,
      Poppins: true,
    },
  },
   generate: {
    fallback: true,
    routes: dynamicRoutes,
    intervall: 3000
  },
  env: {
    apiKey: process.env.GOOGLE_MAPS_API_KEY,
  }
}

The store.dispatch methods are doing the http requets to fetch the data in data.server.js:

export default async ({ store }) => {
  await store.dispatch('getPastGames')
  await store.dispatch('getSpielplan')
  await store.dispatch('getNews')
  await store.dispatch('getImpressum')
  await store.dispatch('getDatenschutz')
  await store.dispatch('getSuperliga')
  await store.dispatch('getPartner')
  await store.dispatch('getTrainingszeiten')
  await store.dispatch('getTabelle')
  await store.dispatch('getPosts')
  await store.dispatch('getNachwuchsteams')
}

Am I trapped in any kind of loop with my API calls? Thank you very much for any help!

Hi @shure77

Loooking at the portion of the deploy you have provided, it comes from the getPastGames Request

The endpoint the function is calling here is returning the 429 error.

So an endpoint might have a limit of 1000 requests per minute (for example.) So waiting 3 seconds before hitting the endpoint isn’t likely to help much.

Thank you. I still was not able to solve the issue. I also did a performance upgrade for my server, which did not help.

@coelmay thank you for your reply. I still do not get where I create so many requests. That only happens when trying to generate the routes dynamically. As soon as I turn off the dynamic route generation, the 429 errors disapear.

Here is also some code snipped of the _slug.vue. Maybe I´m doing something wrong here in connection with VUEX store?

<script>
import { mapState } from 'vuex'
export default {
  data() {
    return {
      newsItem: null,
    }
  },
  computed: {
    ...mapState(['news']),
  },
  beforecreate() {
    this.newsItem = this.news.find(
      (news) => news.id.toString() === this.$route.params.newsid
    )
  },
}
</script>

It is possible. It is something I haven’t used a lot either.

As I see it, this is an issue with your code as you mentioned when dynamic routes are off, the issue disappears. I suggest checking out the Nuxt Discord where you are likely to find people more familiar with what you are trying to implement.

1 Like

I’d personally suggest trying scaling the number of routes down to test. For example start with 10, increase to 100 and see where exactly you get a problem.

1 Like

@hrishikesh thank you. Your suggestion and improving the server performance did the trick. It seems that there was to much data fetched at the same time. I still can´t see the point of the 429 error, as that indicates too many requests and I think I did only one request that got me a lot of data.

So what I did was amending the request parameters from:
wp/v2/news?page=1&per_page=100&embed=1’
to
wp/v2/news?page=1&per
page=10&_embed=1’