---
title: "設定項"
description: "全部環境變數、密鑰與綁定：SETUP_TOKEN、SITE_URL、EMAIL、MAIL_FROM、TRUST_PROXY、DATA_DIR、PORT 等。"
lang: "zh-HK"
version: "1.84.0"
url: "https://docs.calends.date/zh-hk/self-host/config/"
markdown_url: "https://docs.calends.date/zh-hk/self-host/config.md"
section: "自託管"
llms_index: "https://docs.calends.date/llms.txt"
llms_full: "https://docs.calends.date/llms-full.txt"
agents_guide: "https://calends.date/AGENTS.md"
---

# 設定項

> 全部環境變數、密鑰與綁定：SETUP_TOKEN、SITE_URL、EMAIL、MAIL_FROM、TRUST_PROXY、DATA_DIR、PORT 等。

- Canonical page: https://docs.calends.date/zh-hk/self-host/config/
- Markdown source: https://docs.calends.date/zh-hk/self-host/config.md
- Calends version: v1.84.0

部署或排查設定問題時，可在此查閱環境變數、密鑰、綁定與應用設定的預設值。

Calends 大部分設定均在應用介面內調整並儲存於資料庫。部署層面只涉及以下設定項。

## 環境變數與綁定

| 名稱 | 類型 | 適用 | 說明 |
| --- | --- | --- | --- |
| `SETUP_TOKEN` | 密鑰 / 環境變數 | 全部 | 新部署首次設定密碼時必須提供。Cloudflare 使用 `wrangler secret put SETUP_TOKEN` 設定；Docker 未設定時自動產生。設定好密碼後不再需要。 |
| `SITE_URL` | 變數 / 環境變數 | 全部 | 站點網址，例如 `https://calends.example.com`，用於提醒訊息與日曆訂閱中的連結。未設定時：處理請求時採用目前存取網址；定時任務則採用最近一次存取應用時記下的網址。Passkey 的 RP ID 與 origin 亦採用此網址；位於反向代理後方時應設定對外 HTTPS 網址。 |
| `OLD_HOSTS` | 變數 | Cloudflare | 以逗號分隔的舊域名清單，配合 `SITE_URL` 將舊頁面以 HTTP 301 重導至新站；API、MCP、ICS 維持可用。Docker 入口不透傳。 |
| `EMAIL` | 綁定 | Cloudflare | Cloudflare Email Sending 的 `send_email` 綁定，電郵提醒所需。 |
| `MAIL_FROM` | 變數 | Cloudflare | 寄件地址，必須為 `EMAIL` 綁定中允許的地址。須與 `EMAIL` 同時設定，電郵渠道才可使用。 |
| `MAIL_FROM_NAME` | 變數 | Cloudflare | 寄件人名稱，可選。 |
| `TRUST_PROXY` | 環境變數 | 自託管 | 通常留空，自動判斷訪客 IP。`off` 代表不讀取 `X-Forwarded-For`；逗號分隔的 IP/CIDR 清單可追加信任代理。見[自訂域名與 HTTPS](https://docs.calends.date/zh-hk/self-host/custom-domain.md)。Cloudflare 不使用此變數。 |
| `DATA_DIR` | 環境變數 | 自託管 | 資料目錄：Docker 為 `/data`，systemd 單元為 `/var/lib/calends`。 |
| `HOST` | 環境變數 | 自託管 | 監聽位址，預設 `0.0.0.0`。systemd 置於反向代理後方時設 `127.0.0.1`；Docker 維持預設並限制發佈連接埠。 |
| `PORT` | 環境變數 | 自託管 | 監聽連接埠，預設 `8787`。 |
| `OWNER_PASSCODE` | 密鑰 | 舊版 | 早期版本把口令直接存於密鑰中。首次以此登入成功後會轉存為雜湊，之後可刪除。新部署無須設定。 |
| `CALENDS_TELEMETRY`、`DO_NOT_TRACK` | 變數 / 環境變數 | 全部 | `CALENDS_TELEMETRY=0` 或 `DO_NOT_TRACK=1` 會關閉匿名使用統計，且設定內無法再開啟。統計僅含隨機安裝 ID、版本、運行方式、介面語言與每日使用次數，不含任何訂閱、金額或帳本資料。 |
| `CALENDS_RUNTIME` | 環境變數 | 自託管 | 運行方式識別（`node` 或 `installer`，預設 `node`），供升級面板與統計區分部署方式。 |
| `CALENDS_LOCAL` | 環境變數 | 原始碼部署 | 儲存庫外的個人設定目錄（取代 `local/`，內含個人 `wrangler.jsonc` 與 `public/` 覆蓋資源）。 |
| `DEV_BYPASS_AUTH` | `.dev.vars` | 本機開發 | 設為 `1` 時略過登入與匿名統計。僅限本機使用，切勿用於正式環境。 |

在 Cloudflare 上，變數可寫入 `wrangler.jsonc` 的 `vars`，或在控制台的 Worker 設定新增；密鑰透過 `wrangler secret put` 設定。在 Docker 中全部透過環境變數設定。

## 應用內的設定

以下項目並非環境變數，於應用介面內調整：

| 設定 | 位置 | 預設 |
| --- | --- | --- |
| 基準貨幣 | 設定 → 一般 | USD |
| 時區 | 設定 → 一般 | UTC |
| 語言 | 設定 → 一般 | 跟隨系統 |
| 預設提前提醒 | 設定 → 提醒 | 3 天 |
| 傳送時間 | 設定 → 提醒 | 09:00 |
| 每月 1 日帳單預告 | 設定 → 提醒 | 開啟 |
| 公開頁 | 設定 → 開放 | 關閉 |
| AI 存取（MCP） | 設定 → 開放 | 開啟 |
| 最多同時登入 | 設定 → 安全 | 10 台 |
| 匿名使用統計 | 設定 → 一般 | 開啟 |

## 自託管建置與記憶體

映像檔的 `NODE_OPTIONS` 預設為 `--max-old-space-size=192 --disable-warning=ExperimentalWarning`。調整堆積上限時請保留警告開關。`BASE_PATH` 的 Docker 建置參數與執行期值必須一致，例如 `/calends`；預建置映像檔與發佈壓縮包皆按根路徑建置。

## 路由

| 路徑 | 內容 |
| --- | --- |
| `/` | 登入後跳轉至設定中的啟動頁 |
| `/overview` | 概覽 |
| `/list` | 訂閱 |
| `/calendar` | 日曆 |
| `/report` | 報告 |
| `/wallet` | 錢包 |
| `/family` | 共享與人員 |
| `/behalf` | 代付 |
| `/assistant` | 內置 AI 助手 |
| `/connect` | AI 存取與 MCP 連接頁 |
| `/settings` | 設定 |
| `/settings/public` | 公開頁編輯器 |
| `/login` | 登入與首次設定密碼 |
| `/public` | 唯讀公開頁，只在設定中開啟後可存取 |
| `/api/*` | 應用與公開頁使用的介面 |
| `/mcp` | MCP 伺服端點；瀏覽器開啟時跳轉至 `/connect` |
| `/cal/<令牌>.ics` | 日曆訂閱 |
| `/healthz` | 自託管健康檢查（直接檢查 SQLite，不進入 Worker） |

未登入存取應用頁面會跳轉至 `/login?next=...`，登入後返回原頁面。例如存取 `/wallet` 會先進入 `/login?next=%2Fwallet`，登入後回到 `/wallet`。

未登入訪客開啟 `/` 時，若已開啟公開頁則跳轉至 `/public`，否則跳轉至 `/login`。

---

## Related Pages & Global AI Discovery

To explore broader context beyond this page, fetch any of the Markdown or plain-text resources below directly:

### Same Section (自託管)
- [Cloudflare Workers + D1](https://docs.calends.date/zh-hk/self-host/cloudflare.md)
- [Docker](https://docs.calends.date/zh-hk/self-host/docker.md)
- [設定項](https://docs.calends.date/zh-hk/self-host/config.md) *(current)*
- [自訂域名與 HTTPS](https://docs.calends.date/zh-hk/self-host/custom-domain.md)
- [升級](https://docs.calends.date/zh-hk/self-host/upgrade.md)
- [本機開發](https://docs.calends.date/zh-hk/self-host/development.md)
- [參與翻譯](https://docs.calends.date/zh-hk/self-host/translate.md)

### Reading Order
- Previous: [Docker](https://docs.calends.date/zh-hk/self-host/docker.md)
- Next: [自訂域名與 HTTPS](https://docs.calends.date/zh-hk/self-host/custom-domain.md)

### Global Calends Resources
- Read-only Docs MCP Server (zero auth Streamable HTTP): https://docs.calends.date/mcp
- Complete Docs Index (all 37 topics with `.md` links): https://docs.calends.date/llms.txt
- Complete English Docs Bundle (single file): https://docs.calends.date/llms-full.txt
- Complete Simplified Chinese Docs Bundle: https://docs.calends.date/llms-zh.txt
- Docs AI Agent Guide: https://docs.calends.date/AGENTS.md
- Product Website Overview (Markdown): https://calends.date/zh-hk/index.md
- Product LLMs Index & Full Reference: https://calends.date/llms.txt | https://calends.date/llms-full.txt
- Deployment & MCP Agent Guide (AGENTS.md): https://calends.date/AGENTS.md
- FAQ & Calends vs Wallos Comparison (Markdown): https://calends.date/en/faq.md | https://calends.date/en/compare.md
- Complete Changelog (Markdown): https://calends.date/en/releases.md
