Search code examples
gatsbynetlify

Not able to deploy Gatsby + Netlify + DatoCMS


I'm currently using this starter https://github.com/brohlson/gatsby-datocms-starter for a site I'm creating. I wanted to connect that to Netlify for automatic deployments so I:

Went to Netlify and added my Github repo Added the webhook on DatoCMS

This is the error I'm getting during the deploy:

4:48:29 PM: error #11321 PLUGIN 401 INVALID_SITE (details: {})
4:48:29 PM: "gatsby-source-datocms" threw an error while running the sourceNodes lifecycle:
4:48:29 PM: 401 INVALID_SITE (details: {})
4:48:29 PM: See our docs page for more info on this error: https://gatsby.dev/issue-how-to
4:48:29 PM: 
4:48:29 PM:   ApiException: 401 INVALID_SITE (details: {})
4:48:29 PM:   
4:48:29 PM:   - Client.js:120 
4:48:29 PM:     [repo]/[datocms-client]/lib/Client.js:120:33
4:48:29 PM:   
4:48:29 PM:   - next_tick.js:68 process._tickCallback
4:48:29 PM:     internal/process/next_tick.js:68:7
4:48:29 PM:   
4:48:29 PM: 
4:48:29 PM: Function Dir: /opt/build/repo/functions

Any ideas?


Solution

  • I was missing the token as talves mentioned above. I've added DATO_CMS_TOKEN as the documentation says but I realized that my .env config file was set as DATO_CMS_KEY so it was never loading.

    Always pay attention to the env variables! (That's a reminder for me)