---
name: feedback-direct-upload-does-not-deploy-functions
description: 2026-06-06 確立 永続 architectural rule。CF Pages の direct upload は static dist/ のみ反映し、CF Pages Functions (functions/ ディレクトリ) は git integration 経由でしか deploy されない。 direct upload で API endpoint が「HTTP 200 + content fallback」 pattern になる根本原因。
metadata: 
  node_type: memory
  type: feedback
  originSessionId: a6324bca-9de8-4a9b-b2e6-c1ab4bb24169
---

# CF Pages direct upload は Functions を deploy しない

## 確立 trigger (2026-06-06 incident)

WIC project で GitHub auto-deploy 切れ + 5 days 4 commit stuck 状態。 私が「direct upload で deploy する」 path を提案 → 2 回 direct upload 実施。

結果:
- ✅ static page (`/shipping/`, `/honest-confluence/`, `/random-vs-real/`) は反映
- ❌ **API endpoint (`/api/economic-calendar`, `/api/finnhub`, `/api/fred`, `/api/vote`) 全部 missing**
- ❌ `/api/economic-calendar?range=week` → HTTP 200 OK + Content-Type text/html + body は homepage HTML (CF Pages SPA fallback)
- → frontend Economic Calendar が「⚠ fetch failed」 で error 表示

curl + grep verify で初めて気づいた:
```
$ curl -sI https://world-investment-center.pages.dev/api/economic-calendar?range=week
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8        ← ★ JSON でない!

$ curl -s https://world-investment-center.pages.dev/api/economic-calendar?range=week | head -c 50
<!DOCTYPE html><html lang="en"> <head><meta...      ← ★ homepage HTML
```

## 根本 architectural rule

| Deploy 経路 | static dist/ | CF Pages Functions |
|---|---|---|
| **Direct upload** (dashboard で folder drop) | ✅ deploy | ❌ **deploy されない** |
| **Git integration** (GitHub push 自動 build) | ✅ deploy | ✅ deploy |

理由: CF Pages は git push 経由で source code 全体を read して `functions/` directory を Workers として build + deploy する設計。 dashboard direct upload は「static asset upload」 機能で `functions/` 構造を解釈しない。

## 永続原則

1. **`functions/api/*` を使う project は GitHub integration 必須**。 direct upload は static fallback としてのみ使用可。
2. **API endpoint deploy verify には curl + Content-Type + body grep の triple check 必須**。 HTTP 200 だけでは不十分 (CF Pages SPA fallback が HTML を 200 で返す)。
3. **Git integration 切れた project の direct upload は危険**: static 部分だけ反映で API が silent fallback → frontend で「fetch failed」 が表面化するまで気づかない。

## 防衛 protocol

deploy verify 時の triple check:
```bash
# 1. HTTP status
curl -sI <api-endpoint>

# 2. Content-Type が application/json か (text/html なら SPA fallback)
curl -sI <api-endpoint> | grep -i Content-Type

# 3. Body の JSON marker grep (homepage HTML でないことを verify)
curl -s <api-endpoint> | head -c 200 | grep -oE '"[a-z]+":'
```

## 加えて: site visible deploy verify protocol 強化

[[feedback-deploy-verify-http-200-plus-content-grep-required]] の triple-verify を更に厳格化:
- (a) HTTP 200
- (b) **Content-Type が application/json (API) or text/html (page) で expected と一致**
- (c) **unique content marker grep** (homepage HTML / placeholder fallback でない)
- (d) **直近 git log + cron rebuild commit 確認** (取り込み状況)
- (e) **CF Pages dashboard Settings → Git integration status 確認** (disconnect なら direct upload しかできない state)

## 関連

- [[feedback-deploy-verify-http-200-plus-content-grep-required]] (06-05 朝確立、本原則の親)
- [[feedback-deploy-verify-violation-same-day-2026-06-05]] (4 段違反 + 本 session で 5 段目 recurrence)
- [[project-session-2026-06-06-step1192-wic-shipping-calendar-audit]] (本原則確立 incident の full session record)
