---
title: "設定項"
description: "所有環境變數、機密與綁定一覽：SETUP_TOKEN、SITE_URL、EMAIL、MAIL_FROM、TRUST_PROXY、DATA_DIR、PORT 等。"
lang: "zh-TW"
version: "1.84.0"
url: "https://docs.calends.date/zh-tw/self-host/config/"
markdown_url: "https://docs.calends.date/zh-tw/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-tw/self-host/config/
- Markdown source: https://docs.calends.date/zh-tw/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-tw/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`）；預建置映像檔與 Release 壓縮檔皆採根路徑建置。

## 路由

| 路徑 | 內容 |
| --- | --- |
| `/` | 登入後跳轉至設定中的啟動頁 |
| `/overview` | 概覽 |
| `/list` | 訂閱 |
| `/calendar` | 行事曆 |
| `/report` | 報告 |
| `/wallet` | 錢包 |
| `/family` | 共享與人員 |
| `/behalf` | 代付 |
| `/assistant` | 內建 AI 助手 |
| `/connect` | 連接 AI 助手（MCP） |
| `/settings` | 設定 |
| `/settings/public` | 公開頁編輯器 |
| `/login` | 登入與首次密碼設定 |
| `/public` | 唯讀公開頁，僅在設定中開啟後可造訪 |
| `/api/*` | 應用與公開頁使用的 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-tw/self-host/cloudflare.md)
- [Docker](https://docs.calends.date/zh-tw/self-host/docker.md)
- [設定項](https://docs.calends.date/zh-tw/self-host/config.md) *(current)*
- [自訂網域與 HTTPS](https://docs.calends.date/zh-tw/self-host/custom-domain.md)
- [升級](https://docs.calends.date/zh-tw/self-host/upgrade.md)
- [本機開發](https://docs.calends.date/zh-tw/self-host/development.md)
- [參與翻譯](https://docs.calends.date/zh-tw/self-host/translate.md)

### Reading Order
- Previous: [Docker](https://docs.calends.date/zh-tw/self-host/docker.md)
- Next: [自訂網域與 HTTPS](https://docs.calends.date/zh-tw/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-tw/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
