配置
🌐 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
基础配置
🌐 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 文件中 | 可选地用于执行服务器生命周期中发生的各种操作。包括 register、bootstrap 和 destroy 函数。 |
| Cron 作业 |
| 需要为服务器设置 CRON 作业。 |
| 环境变量 | 在专门用于环境的文件和文件夹中(例如,config/env/production/server) | 可选择用于定义不同的环境及其变量。 |
| 单点登录 (SSO) EnterpriseThis feature is available with an Enterprise plan. SSOThis feature is available with the SSO add-on. | 在 config/admin 文件中 | 如果在你的项目中启用了 SSO 功能,则需要使用该功能。 |
| 功能标志 | 在 config/features 文件中 | 对于典型的、稳定的 Strapi 应用是可选的。 仅在需要启用未来标志时才需要。 |
指南
🌐 Guides
以下指南将帮助你解决与 Strapi 配置相关的特定用例:
🌐 The following guides will help you address specific use cases related to the Strapi configuration: