Skip to content

Gatsby Config requires definition for "apiHost" #271

@stbly

Description

@stbly

After updating to gatsby-source-sanity v7.9.0, node started throwing an obscure error right after Gatsby's onPreInit hook:

success onPreInit - 0.003s
info [sanity] Fetching remote GraphQL schema
error Cannot read properties of undefined (reading 'split')

I was eventually able to figure out that it was because apiHost was reading as undefined in the Sanity config. I didn't see anything in the documentation saying this needed to be provided in gatsby-config.js, but after adding it everything ran fine:

{
      resolve: 'gatsby-source-sanity',
      options: {
        ...
        apiHost: 'https://api.sanity.io',
        ....
      },
    },
}

I was also able to replicate this issue by starting a new gatsby project using Sanity as a source.

Node Version: v18.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions