Gatsby-source-prismic - unable to access the Prismic repository

Hi,
Firstly, I'd like to say I love the way this CMS works for editing and creating types etc., so I'd really like to use it in a client project.
However, I'm having some issues linking this to a Gatsby site. I've followed the documentation, but can't seem to get my gatsby-source-prismic plugin set up.

When running gatsby develop and starting the dev server, build fails on loading plugins, specifically on the gatsby-source-prismic plugin. I get a console message saying:
"

  • gatsby-source-prismic([repository name]) - Unable to access the Prismic repository. Check that the correct repository name and access token are provided."

I have set up the plugin as follows (all hardcoded in for now):

    resolve: "gatsby-source-prismic",
    options: {
      repositoryName: "[repository name]",
      accessToken: "[access token from API & security => content API => Permanent access tokens]",
      customTypesApiToken: "[token from API & security => custom types API => tokens]" ,
    }
  }

When using the API Browser, I can see my content in there, so I'm thinking it's an issue with configuring the plugin.
Any advice would be greatly appreciated!

Hello @josh.ferriday thanks for reching out.

We need to check what step is breaking in your setup. Where is your gatsby-config.js file getting your project data from?

Hi Pau,
Thank you the response.
At the moment, the project data (accessToken, customTypesApiToken and repository name) are all hard coded into the gastby config file (to eliminate issues with a .env file).

I see. Then it's very odd that it isn't getting it when you run the project. Do you have a screenshot of the error?

hi @Pau

We seem to be having the same issue and cannot get pass error below. We've checked and we are setting up our plugin correctly in gatsby-config.

Please let us know what else we could check. We are also looking in case its a firewall issue.

Error

Invalid plugin options for "gatsby-source-prismic":


gatsby-source-prismic(REPO_NAME) - Unable to access the Prismic repository. Check the repository name. If the repository is secured, provide an access token.

gatsby-config.js

    {
      resolve: `gatsby-source-prismic`,
      options: {
        repositoryName: process.env.GATSBY_PRISMIC_REPO_NAME,
        accessToken: process.env.PRISMIC_ACCESS_TOKEN,
        customTypesApiToken: process.env.PRISMIC_CUSTOM_TYPES_API_TOKEN,
        linkResolver: (doc) => linkResolver(doc),
        schemas: {
          article_template: require('./custom_types/article_template.json'),
          author: require('./custom_types/author.json'),
          award: require('./custom_types/award.json'),
          category: require('./custom_types/category.json'),
          culture_blog_post: require('./custom_types/culture_blog_post.json'),
          faq: require('./custom_types/faq.json'),
          navigation: require('./custom_types/navigation.json'),
          price_card: require('./custom_types/price_card.json'),
          redirect: require('./custom_types/redirect.json'),
          section: require('./custom_types/section.json'),
          site_configuration: require('./custom_types/site_configuration.json'),
          template_page: require('./custom_types/template_page.json'),
          testimonial: require('./custom_types/testimonial.json'),
          theme: require('./custom_types/theme.json'),
          video_portal: require('./custom_types/video_portal.json'),
        }
      },
    },

Hey @char.lopez11, when are you seeing this error, in development mode or when you build the project? maybe your build isn't recognizing environment variables.