Gatsby 我能';I don’我对盖茨比很满意
当我尝试与Gatsby连接到Contentful时,我收到以下错误消息:Gatsby 我能';I don’我对盖茨比很满意,gatsby,contentful,Gatsby,Contentful,当我尝试与Gatsby连接到Contentful时,我收到以下错误消息: Starting to fetch data from Contentful info Fetching default locale ERROR Accessing your Contentful space failed. Try setting GATSBY_CONTENTFUL_OFFLINE=true to see if we can serve from cache. Used options: sp
Starting to fetch data from Contentful
info Fetching default locale
ERROR
Accessing your Contentful space failed.
Try setting GATSBY_CONTENTFUL_OFFLINE=true to see if we can serve from cache.
Used options:
spaceId: "*******ed"
accessToken: "*******ed"
host (default value): "cdn.contentful.com"
environment (default value): "master"
downloadLocal (default value): false
localeFilter (default value): [Function]
forceFullSync (default value): false
pageLimit (default value): 100
useNameForId (default value): true
not finished source and transform nodes - 0.320s
我在gatsby-config.js中的代码:
module.exports = {
siteMetadata: {
title: `Gatsby`,
siteUrl: `http://localhost8000`,
author: '****',
},
plugins: [
{
resolve: `gatsby-source-contentful`,
options: {
spaceId: ${`process.env.CONTENTFUL_SPACE_ID`},
accessToken: ${`process.env.CONTENTFUL_ACCESS_TOKEN`},
// My code only works with this syntax ${`...`}
}
},
]
}
我在此页面上看到了的响应:。他覆盖并创建内容空间,并在本地重新启动初始脚本“rg portfolio”,该脚本本机包含内容配置。它还引用starter中的“contentful data.json”文件
我使用“hello world”启动程序,所以我自己添加了gatsby source contentful插件,它没有创建“contentful data.json”文件,而且我在页面上也没有看到关于这个json文件的任何信息。
我删除并重新创建了我的内容空间,然后重新安装了插件,但它仍然不起作用
有什么想法吗?我注意到您如何处理字符串文本的问题 更改此项:
spaceId: ${`process.env.CONTENTFUL_SPACE_ID`},
accessToken: ${`process.env.CONTENTFUL_ACCESS_TOKEN`},
进入以下任何一种(推荐的):
或者这个:
spaceId: `${process.env.CONTENTFUL_SPACE_ID}`,
accessToken: `${process.env.CONTENTFUL_ACCESS_TOKEN}`,
你能分享你的gatsby-config.js中有内容的部分吗?:)你的
gatsby-config
应该看起来像@andyhofman是的,我试图用这种方式编写代码,但我不知道为什么它不起作用。我收到一条错误消息,因为它无法将其识别为字符串。
spaceId: `${process.env.CONTENTFUL_SPACE_ID}`,
accessToken: `${process.env.CONTENTFUL_ACCESS_TOKEN}`,