gpt4 book ai didi

docker - Strapi 路由返回 404 未找到

转载 作者:行者123 更新时间:2023-12-03 17:33:46 24 4
gpt4 key购买 nike

我有一个问题,我的 API 中的所有路由都返回 404 Not found .我关注了从 Docker 中心拉取 strapi/strapi-docker的部分.

除了运行图像之外,我所做的是创建一个名为 post 的新内容类型。包含三个字段。如果我尝试 GET /post (添加所有帖子)我收到未经授权的响应错误。这是现阶段的预期。在我检查角色和权限以允许公共(public)角色使用 find 和 findOne 路由后,即使已添加数据,我也会收到 404 Not found 响应错误。

开发服务器不使用任何前缀。
post find 和 findOne 的路线如下所示:

{
"routes": [
{
"method": "GET",
"path": "/post",
"handler": "Post.find",
"config": {
"policies": []
}
},
{
"method": "GET",
"path": "/post/:_id",
"handler": "Post.findOne",
"config": {
"policies": []
}
}
}

Strapi 界面中没有太多可供选择的选项,所以我不确定还有什么可以尝试的。我已经尝试了几个其他的strapi安装。不确定这是否会搞砸,但我隐约记得之前尝试过strapi/strapi-docker并让它工作。

最佳答案

我多次偶然发现这个问题,最简单的答案通常是:
你发表过你的任何帖子吗?
Strapi 有一个发布子系统,通常在创建任何集合、单一类型或组件时打开。
enter image description here
因此,当您创建任何已创建类型的任何内容时,数据将保存为草稿并且不公开。
这是我的链接集合类型。它已保存,但未发布。
enter image description here
因此,如果您尝试测试端点,但您只有一个数据条目并且它设置为草稿,则不会显示任何数据。
enter image description here
没有数据!
enter image description here
未发表的单一类型的情况
enter image description here
这将返回 404!
enter image description here
发布,瞧...
enter image description here
这可能是 Strapi 向您发送 404 或仅发送空数组的原因之一!

关于docker - Strapi 路由返回 404 未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50042524/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com