简体   繁体   English

(Gatsby-Strapi) 错误:请求失败,状态码为 404

[英](Gatsby-Strapi) Error: Request failed with status code 404

I want to follow the instruction: https://strapi.io/blog/building-a-static-website-using-gatsby-and-strapi#allowaccess我想按照说明进行操作: https://strapi.io/blog/building-a-static-website-using-gatsby-and-strapi#allowaccess

But encounter Error: Request failed with status code 404但遇到错误:请求失败,状态码为 404

Node.js version: v10.13.0 npm version: 6.14.6 Strapi version: 3.1.0-alpha.5 Operating system: mac Node.js 版本:v10.13.0 npm 版本:6.14.6 Strapi 版本:3.1.0-alpha.5 操作系统:mac

Which example is causing problem?哪个示例导致问题? strapi.io/blog/building-a-static-website-using-gatsby-and-strapi#allowaccess Strapi.io/blog/building-a-static-website-using-gatsby-and-strapi#allowaccess

What is the current behavior?当前的行为是什么? Graphql Query doesn't work. Graphql 查询不起作用。

the steps to reproduce the problem:重现问题的步骤:

$ 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

What is the expected behavior?预期的行为是什么? What is the expected behavior?预期的行为是什么?

Doesn't work when I try to get from gatsby http://localhost:8000/___graphql当我尝试从 gatsby http://localhost:8000/___graphql 获取时不起作用

There is no method allStrapiblogs on http://localhost:8000/___graphql http://localhost:8000/___graphql 上没有方法 allStrapiblogs

Please share your gatsby-config.js screen, the gatsby-source-strapi section.请分享您的 gatsby-config.js 屏幕, gatsby-source-strapi部分。

this could be caused by the collectionTypes/singleTypes in the gatsby-source-strapi , or your USERS & PERMISSIONS PLUGIN (roles) in strapi is not set这可能是由gatsby-source-strapi中的 collectionTypes/singleTypes 引起的,或者您未设置 Strapi 中的用户和权限插件(角色)

This code solved my problem.这段代码解决了我的问题。

{
  resolve:'gatsby-source-strapi',
  options:{
      apiURL:'*http://localhost:1337/admin/content-manager/collectionType/api::*',
     
      collectionTypes: ['propiedads','paginas','categorias'],
      queryLimit:1000
    }
}

There has been update to the plugin, more info about it is found in this article: https://strapi.io/blog/introducing-the-new-gatsby-source-strapi-plugin插件已经更新,更多信息可以在这篇文章中找到: https://strapi.io/blog/introducing-the-new-gatsby-source-strapi-plugin

I've changed contentTypes to collectionTypes and also added /api to my url我已将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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM