如何在重启 Strapi 后编辑内容

如何在重启 Strapi 后编辑内容

当我重新开始 strapi,我无法再编辑内容,收到此警告:

The autoreload feature is required to use this plugin. 
Start your server with strapi develop

答案1

为了解决正确的问题,我需要更多细节,但是,我在使用时遇到了同样的问题yarn start。相反,我使用了yarn strapi dev,它strapi以正确的配置运行。

我可以运行服务器并编辑内容;但是,我最初尝试更改生产和暂存server.json文件以包含以下内容,但这不起作用。

"autoReload": {
  "enabled": true
},

答案2

我也遇到了同样的问题。我通过运行解决了该问题npx strapi dev

在项目开发过程中,为了自定义(添加/删除/修改)API 的内容,您需要以开发模式启动服务器,这可以通过 npx strapi dev 完成。这里有一整本命令行手册这里

答案3

当我开始使用 Strapi 时,我相信我可以在生产中创建/编辑/删除内容类型。但这是不可能的。

Strapi 的注释:


### Why can't I create or update content-types in production/staging?

Strapi stores model configuration files (what defines the model schema) in files such as `api/restaurant/models/restaurant.settings.json`. Due to how Node.js works, in order for changes to take effect, that would require Node to restart the server. This could potentionally cause downtime of your production service and likewise these changes should be tracked in some kind of source control.

Generally your "flow" of development would follow the following path:

- Development - Develop your Strapi application locally on your host machine, then push changes into source control
- Staging - Deploy changes from source control to a "production-like" environment for testing
- Production - If no other changes are needed, deploy into production
- Repeat as needed, it is recommended that you properly version and test your application as you go

At this time and in the future there is no plan to allow model creating or updating while in a production environment, and there is currently no plans to move model settings into the database. There is no known nor recommended workarounds for this.

我应该怎么办

您需要在开发模式下在本地创建架构npm run develop。然后您必须将 repo(其src/api文件夹下将有架构)提交到 Git repo。在生产中,您必须拉取 repo 并将其运行为

NODE_ENV=production npm run start

相关内容