Skip to main content

配置

¥Configuration

Strapi 项目的配置位于 /config 文件夹中:

¥The configuration of a Strapi project lives in the /config folder:

. # root of the project
├──── config
│ ├ api.js|ts
│ ├ admin.js|ts
│ ├ cron-tasks.js|ts
│ ├ database.js|ts
│ ├ features.js|ts
│ ├ middlewares.js|ts
│ ├ plugins.js|ts
│ └ server.js|ts
上面的块是项目结构的摘录。你可以点击任意文件名来阅读相应的文档。访问 项目结构页面 获取完整版本。

¥The block above is an excerpt from the project structure. You can click on any file name to read the corresponding documentation. Visit the project structure page for the full version.

基本配置

¥Base configurations

/config 文件夹中,你可以找到并定义以下基本配置:

¥From the /config folder, you can find and define the following base configurations:

配置主题文件路径必需或可选
数据库config/database必需的
服务器config/server必需的
管理面板config/admin必需的
中间件config/middlewares必需的
API 调用config/api可选,用于定义响应的一些常规设置和其他 REST 相关参数。

特定功能的附加配置

¥Additional configuration for specific features

一些特定功能需要额外配置:

¥Some specific features require additional configuration:

特性地点必需或可选
插件config/plugins 文件中
TypeScript有效使用 TypeScript 所需
API 令牌config/admin 文件中如果使用 API 令牌而不是 用户和权限插件 进行身份验证,则为必需
生命周期函数/src/index 文件中可选择用于执行服务器生命周期中发生的各种操作。包括 registerbootstrapdestroy 功能。
Cron 作业需要为服务器设置 CRON 作业。
环境变量在环境的专用文件和文件夹中(例如,config/env/production/server可选择用于定义不同的环境及其变量。
单点登录 (SSO) <企业徽章/>config/admin 文件中如果你的项目启用了仅限企业的 SSO 功能,则需要使用该功能。
功能标志config/features 文件中对于典型、稳定的 Strapi 应用来说是可选的。
仅需要启用 未来的标志

指南

¥Guides

以下指南将帮助你解决与 Strapi 配置相关的特定用例:

¥The following guides will help you address specific use cases related to the Strapi configuration: