| sidebar_position | 1 | |||||
|---|---|---|---|---|---|---|
| title | 项目配置项 | |||||
| description | ReactPress 配置参考 — .reactpress/config.json、.env 同步、端口、数据库与生产环境变量说明。 | |||||
| keywords |
|
ReactPress 以 .reactpress/config.json 为配置源;.env 由 CLI 在 init / config --apply 时自动同步,多数用户无需手写。
4.0 桌面本地模式使用独立站点目录(如
.reactpress/desktop-dev-site/),内含 SQLite 专用.env(DB_TYPE=sqlite),与全栈 MySQL 站点配置分离。详见 desktop/README.md。
典型结构(字段因版本可能略有增减):
{
"server": { "port": 3002 },
"client": { "port": 3001 },
"database": {
"mode": "embedded-docker",
"host": "127.0.0.1",
"port": 3306,
"user": "reactpress",
"password": "reactpress",
"database": "reactpress"
},
"urls": {
"client": "http://localhost:3001",
"server": "http://localhost:3002"
}
}database.mode:embedded-docker(默认)或外部 MySQL 等模式- 修改后:
reactpress config --apply同步.env并按需重启
查看与修改:
reactpress config
reactpress config server.port 3003 --apply项目启动时加载根目录 .env,主要变量如下(由 config 同步,一般勿手改):
# 数据库
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=reactpress
DB_PASSWD=reactpress
DB_DATABASE=reactpress
# 站点 URL
CLIENT_SITE_URL=http://localhost:3001
SERVER_SITE_URL=http://localhost:3002
# Github OAuth(可选)
GITHUB_CLIENT_ID=0
GITHUB_CLIENT_SECRET=0- 在
config.json中将database.mode改为外部库对应配置 - 执行
reactpress config --apply - 运行
reactpress doctor确认连接