js
module.exports = {
host: '0.0.0.0',
}
那么可以这样访问 server.host 键:
js
strapi.config.get('server.host', 'defaultValueIfUndefined')
嵌套键可通过 点符号 访问。
文件名用作访问配置的前缀。
配置文件可以是 .js 或 .json 文件。
使用 .js 文件时,可以导出配置:
- 作为对象:
js
module.exports = {
mySecret: 'someValue',
}
- 或作为返回配置对象的函数(推荐使用)。该函数将访问
env实用程序:
js
module.exports = ({ env }) => {
return {
mySecret: 'someValue',
}
}