---
title: "Cloudflare Workers + D1"
description: "원클릭 또는 명령줄로 본인의 Cloudflare 계정에 Calends를 배포하고 D1 데이터베이스, Cron 트리거, 선택적 이메일 알림을 구성합니다."
lang: "ko"
version: "1.84.0"
url: "https://docs.calends.date/ko/self-host/cloudflare/"
markdown_url: "https://docs.calends.date/ko/self-host/cloudflare.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"
---

# Cloudflare Workers + D1

> 원클릭 또는 명령줄로 본인의 Cloudflare 계정에 Calends를 배포하고 D1 데이터베이스, Cron 트리거, 선택적 이메일 알림을 구성합니다.

- Canonical page: https://docs.calends.date/ko/self-host/cloudflare/
- Markdown source: https://docs.calends.date/ko/self-host/cloudflare.md
- Calends version: v1.84.0

D1, 예약 작업, 선택적 이메일 알림과 함께 본인의 Cloudflare 계정에 Calends를 배포하세요.

Calends는 Cloudflare Worker 앱입니다. 프런트엔드는 Worker의 정적 자산으로 제공되고 데이터는 D1(SQLite)에 저장되며 알림과 환율 갱신은 Cron 트리거로 실행됩니다. 사용량과 비용은 본인 Cloudflare 계정의 요금제와 할당량에 따라 달라집니다.

## 요구 사항

- Cloudflare 계정
- 명령줄 배포 시 Node.js 24 및 git

## 원클릭 배포

[Deploy to Cloudflare](https://deploy.workers.cloudflare.com/?url=https://github.com/imetn/calends)를 열고 안내에 따라 저장소를 본인 GitHub 계정에 복사한 뒤 배포하세요.

그다음 Cloudflare 대시보드에서 Worker의 **Settings → Variables and Secrets**를 열고 긴 무작위 문자열 값으로 `SETUP_TOKEN` 시크릿을 추가하세요. 이 값이 없으면 비밀번호를 설정할 수 없습니다.

## 명령줄 배포

1. 저장소를 복제하고 패키지를 설치합니다.

   ```bash
   git clone https://github.com/imetn/calends && cd calends
   npm ci
   ```

2. Cloudflare에 로그인하고 `npx wrangler whoami`로 계정을 확인합니다.

   ```bash
   npx wrangler login
   ```

3. 설정 토큰을 등록합니다.

   ```bash
   npx wrangler secret put SETUP_TOKEN
   ```

   무작위 값은 예를 들어 `openssl rand -base64 24`로 생성할 수 있습니다.

4. 배포합니다.

   ```bash
   npm run deploy
   ```

5. `https://calends.<your-subdomain>.workers.dev`를 열고 설정 토큰을 입력한 뒤 비밀번호를 설정합니다.

`npm run deploy`는 다음 작업을 순서대로 수행합니다.

1. 마이그레이션 및 번역 파일을 생성하고 타입 검사를 거친 뒤 Vite로 프런트엔드를 빌드합니다.
2. `wrangler deploy`로 Worker를 배포합니다. 첫 배포 시 `calends`라는 D1 데이터베이스가 자동 생성되므로 `database_id`를 직접 채울 필요가 없습니다.
3. 원격 데이터베이스에 모든 마이그레이션을 적용합니다.

Worker는 각 인스턴스가 첫 요청을 처리할 때도 누락된 마이그레이션을 확인해 적용하므로 원클릭 배포에서도 그대로 동작합니다.

## wrangler.jsonc

저장소의 `wrangler.jsonc`는 바로 사용할 수 있도록 구성되어 있습니다.

| 항목 | 역할 |
| --- | --- |
| `assets` | 프런트엔드 정적 자산. `/api/*`, `/cal/*`, `/mcp`는 Worker가 먼저 처리하고 나머지 경로는 SPA로 폴백합니다. |
| `d1_databases` | 바인딩 이름 `DB`, 데이터베이스 `calends`. |
| `triggers.crons` | `*/15 * * * *`: 15분마다 알림과 재시도를 확인합니다. 환율 관리는 UTC 정각 경계에 실행되어 20시간이 지난 환율을 갱신합니다. |
| `observability` | Workers 로그가 켜져 있어 대시보드에서 알림 발송 결과와 마이그레이션을 확인할 수 있습니다. |

## 이메일 알림

이메일 알림은 [Cloudflare Email Sending](https://developers.cloudflare.com/email-routing/email-workers/send-email-workers/)을 사용합니다. 이메일을 쓰지 않을 경우 이 섹션을 건너뛰어도 됩니다. 다른 모든 알림 채널은 서버 설정이 필요 없습니다.

1. Cloudflare에서 본인 도메인의 이메일 발송을 활성화하고 `calends@example.com` 같은 발신 주소를 인증합니다.
2. `wrangler.jsonc`에서 다음 두 항목의 주석을 해제하고 수정합니다.

   ```jsonc
   "send_email": [{ "name": "EMAIL", "allowed_sender_addresses": ["calends@example.com"] }],
   "vars": { "SITE_URL": "https://calends.example.com", "MAIL_FROM": "calends@example.com", "MAIL_FROM_NAME": "Calends" },
   ```

3. `npm run deploy`로 다시 배포합니다.
4. **설정 → 알림 채널**에서 본인 주소로 이메일 채널을 추가하고 **테스트**를 클릭합니다.

> **NOTE**: `MAIL_FROM_NAME`은 선택 사항이며 비워 두면 인터페이스 언어의 앱 이름을 사용합니다. `SITE_URL` 역시 선택 사항으로, 알림과 캘린더 링크에 쓰이는 주소를 지정합니다. 자세한 내용은 [구성](https://docs.calends.date/ko/self-host/config.md)을 참고하세요.

## 사용자 지정 도메인

[사용자 지정 도메인 및 HTTPS](https://docs.calends.date/ko/self-host/custom-domain.md)를 참고하세요.

## 비용

사용량에는 Workers 요청, D1 읽기·쓰기·스토리지, Cron, 선택적 이메일 발송이 포함됩니다. 실제 사용량과 현재 할당량은 Cloudflare 대시보드에서 확인하세요. 내장 어시스턴트의 DeepSeek 사용량은 Cloudflare와 별개로 본인 DeepSeek 계정에 청구됩니다.

---

## 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/ko/self-host/cloudflare.md) *(current)*
- [Docker](https://docs.calends.date/ko/self-host/docker.md)
- [구성](https://docs.calends.date/ko/self-host/config.md)
- [사용자 지정 도메인 및 HTTPS](https://docs.calends.date/ko/self-host/custom-domain.md)
- [업그레이드](https://docs.calends.date/ko/self-host/upgrade.md)
- [로컬 개발](https://docs.calends.date/ko/self-host/development.md)
- [번역 참여](https://docs.calends.date/ko/self-host/translate.md)

### Reading Order
- Previous: [개인정보 보호](https://docs.calends.date/ko/data/privacy.md)
- Next: [Docker](https://docs.calends.date/ko/self-host/docker.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/ko/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
