[英](Gatsby-Strapi) Error: Request failed with status code 404
我想按照說明進行操作: https://strapi.io/blog/building-a-static-website-using-gatsby-and-strapi#allowaccess
但遇到錯誤:請求失敗,狀態碼為 404
Node.js 版本:v10.13.0 npm 版本:6.14.6 Strapi 版本:3.1.0-alpha.5 操作系統:mac
哪個示例導致問題? Strapi.io/blog/building-a-static-website-using-gatsby-and-strapi#allowaccess
當前的行為是什么? Graphql 查詢不起作用。
重現問題的步驟:
$ gatsby develop
success open and validate gatsby-configs
success load plugins - 2.011s
success onPreInit - 0.004s
success initialize cache - 0.018s
success copy gatsby files - 0.102s
success onPreBootstrap - 0.017s
success createSchemaCustomization -
info Starting to fetch data from Strapi
info Starting to fetch data from Strapi
info Starting to fetch data from Strapi
ERROR #11321 PLUGIN
"gatsby-source-strapi" threw an error while running the sourceNodes lifecycle:
Request failed with status code 404
Error: Request failed with status code 404
createError.js:16 createError
[portfolio_v4]/[gatsby-source-strapi ]/[axios]/lib/core/createError.js:16 :15
settle.js:18 settle
[portfolio_v4]/[gatsby-source-strapi ]/[axios]/lib/core/settle.js:18:12
http.js:202 IncomingMessage.handleSt reamEnd
[portfolio_v4]/[gatsby-source-strapi ]/[axios]/lib/adapters/http.js:202:1 1
task_queues.js:84 processTicksAndRej ections
internal/process/task_queues.js:84:2 1
預期的行為是什么? 預期的行為是什么?
當我嘗試從 gatsby http://localhost:8000/___graphql 獲取時不起作用
http://localhost:8000/___graphql 上沒有方法 allStrapiblogs
請分享您的 gatsby-config.js 屏幕, gatsby-source-strapi
部分。
這可能是由gatsby-source-strapi
中的 collectionTypes/singleTypes 引起的,或者您未設置 Strapi 中的用戶和權限插件(角色)
這段代碼解決了我的問題。
{
resolve:'gatsby-source-strapi',
options:{
apiURL:'*http://localhost:1337/admin/content-manager/collectionType/api::*',
collectionTypes: ['propiedads','paginas','categorias'],
queryLimit:1000
}
}
插件已經更新,更多信息可以在這篇文章中找到: https://strapi.io/blog/introducing-the-new-gatsby-source-strapi-plugin
我已將contentTypes
更改為collectionTypes
並將/api
添加到我的 url
{
resolve: 'gatsby-source-strapi',
options: {
apiURL: 'http://localhost:1337/api',
collectionTypes: [ // List of the Content Types you want to be able to request from Gatsby.
'article',
'user'
],
queryLimit: 1000,
},
},
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.