title: Nuxt Error: Request failed with status code 403
body: <p>I am attempting to deploy my Nuxt app to Netlify, but am receiving errors when <code>yarn run generate</code> is being run.</p>
  <pre><code>9:32:52 AM: $ yarn run generate
  9:32:52 AM: yarn run v1.22.4
  9:32:52 AM: $ nuxt generate
  9:34:06 AM: [error] Could not resolve routes
  9:34:06 AM: [fatal] Request failed with status code 403
  9:34:06 AM:   at createError (node_modules/axios/lib/core/createError.js:16:15)
  9:34:06 AM:   at settle (node_modules/axios/lib/core/settle.js:17:12)
  9:34:06 AM:   at IncomingMessage.handleStreamEnd (node_modules/axios/lib/adapters/http.js:236:11)
  9:34:06 AM:   at IncomingMessage.emit (events.js:203:15)
  9:34:06 AM:   at IncomingMessage.EventEmitter.emit (domain.js:448:20)
  9:34:06 AM:   at endReadableNT (_stream_readable.js:1145:12)
  9:34:06 AM:   at process._tickCallback (internal/process/next_tick.js:63:19)
  9:34:06 AM: 
  9:34:06 AM:    ╭────────────────────────────────────────────────╮
  9:34:06 AM:    │                                                │
  9:34:06 AM:    │   ✖ Nuxt Fatal Error                           │
  9:34:06 AM:    │                                                │
  9:34:06 AM:    │   Error: Request failed with status code 403   │
  9:34:06 AM:    │                                                │
  9:34:06 AM:    ╰────────────────────────────────────────────────╯
  9:34:06 AM: 
  9:34:06 AM: error Command failed with exit code 1.
  9:34:06 AM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
  9:34:06 AM: ​
  9:34:06 AM: ┌─────────────────────────────┐
  9:34:06 AM: │   &quot;build.command&quot; failed    │
  9:34:06 AM: └─────────────────────────────┘
  9:34:06 AM: ​
  9:34:06 AM:   Error message
  9:34:06 AM:   Command failed with exit code 1: yarn run generate
  9:34:06 AM: ​
  9:34:06 AM:   Error location
  9:34:06 AM:   In Build command from settings:
  9:34:06 AM:   yarn run generate
  9:34:06 AM: ​
  9:34:06 AM:   Resolved config
  9:34:06 AM:   build:
  9:34:06 AM:     base: /opt/build/repo
  9:34:06 AM:     command: yarn run generate
  9:34:06 AM:     publish: /opt/build/repo/dist
  9:34:06 AM: Caching artifacts
  9:34:06 AM: Started saving node modules
  9:34:06 AM: Finished saving node modules
  9:34:06 AM: Started saving build plugins
  9:34:06 AM: Finished saving build plugins
  9:34:06 AM: Started saving yarn cache
  9:34:06 AM: Finished saving yarn cache
  9:34:06 AM: Started saving pip cache
  9:34:14 AM: Finished saving pip cache
  9:34:14 AM: Started saving emacs cask dependencies
  9:34:14 AM: Finished saving emacs cask dependencies
  9:34:14 AM: Started saving maven dependencies
  9:34:14 AM: Finished saving maven dependencies
  9:34:14 AM: Started saving boot dependencies
  9:34:14 AM: Finished saving boot dependencies
  9:34:14 AM: Started saving go dependencies
  9:34:16 AM: Finished saving go dependencies
  9:34:16 AM: Error running command: Build script returned non-zero exit code: 1
  9:34:16 AM: Failing build: Failed to build site
  9:34:16 AM: Failed during stage 'building site': Build script returned non-zero exit code: 1
  9:34:16 AM: Finished processing build request in 2m4.577292784s
  </code></pre>
  <p>If I run <code>yarn run generate</code> locally, it works fine. I thought it had to do with the dynamic routes not being generated, but console logging everything locally, those dynamic routes appear to be generated correctly as well. I'm not entirely sure where to even begin with this error, because everything I've looked up seems unrelated or out of date.</p>
  <p>The closest guess I have is that it's axios related in my <code>generateDynamicRoutes.js</code> file:</p>
  <pre><code>import axios from 'axios';
  
  const instance = axios.create({
    baseURL: process.env.STRAPI_BACKEND_BASE,
  });
  
  const dynamicRoutes = async () =&gt; {
  
    // fetch galleries slugs
    const resForGalleries = await instance.get('/galleries');
  
    // fetch images slugs
    const resForImages = await instance.get('/images');
  
    const routesForGalleries = resForGalleries.data.map(gallery =&gt; {
      return {
        route: `/galleries/${gallery.slug}`,
        payload: gallery,
      };
    });
  
    const routesForImages = resForImages.data.map(image =&gt; {
      return {
        route: `/images/${image.slug}`,
        payload: image,
      };
    });
  
    return [...routesForGalleries, ...routesForImages];
  };
  
  export default dynamicRoutes;
  </code></pre>
  <p><em>nuxt.config.js:</em></p>
  <pre><code>import dynamicRoutes from './services/generateDynamicRoutes';
  
  require('dotenv').config();
  
  export default {
    mode: 'universal',
    ...
    generate: {
      routes: dynamicRoutes
    }
  }
  </code></pre>
  <p>Does anyone have a suggestion? Thanks!</p>
  <p><strong>Update:</strong>
  After some investigation, it appears to be because my Strapi backend doesn't have permissions set up yet in production for some reason.</p>