ダブルクリックで英日反転
Applied Sciences · Engineering
Cloudflare Wrangler and Pages Functions
Wrangler is Cloudflare's official CLI for developing and deploying Workers and Pages. Pages Functions extend a static site with serverless backend logic, bundled at build time into a single Worker.
What Wrangler does
- `wrangler dev` — starts a local dev server that mirrors production.
- `wrangler deploy` — publishes your code to Cloudflare's edge network.
- Git integration lets Pages auto-deploy on every push to main, so manual `wrangler deploy` is often unnecessary.
Pages Functions basics
- Place files in the repo-root `functions/` directory; file name = URL path.
- Example: `functions/api/hello.js` is accessible at `/api/hello`.
- Dynamic segments use bracket syntax: `[id].js`.
- At build time all files are bundled into one Worker (the Functions bundle).
Building a REST API
- Export named handlers like `onRequestGet(context)` to match HTTP methods.
- Return `Response.json(...)` for JSON responses.
Common failure causes
- `functions/` placed outside the repo root — files won't be included in the build.
- `_routes.json` `exclude` list contains `/api/*` — requests hit static files instead.
- Pages dashboard has Functions disabled, or `wrangler.toml` is written for Workers, not Pages.
→ Point `functions/` at the repo root, match file names to URL paths, and let Wrangler (or Git) handle the rest.
Applied Sciences · Engineering
Cloudflare Wrangler と Pages Functions
Wrangler(=Cloudflare公式CLI)は Workers / Pages の開発・デプロイを担うツール。Pages Functions は静的サイトにサーバーレスのバックエンド処理を追加する仕組みで、ビルド時に単一の Worker へバンドルされる。
Wrangler の役割
- `wrangler dev` — 本番に近い環境をローカルで再現するdev サーバーを起動。
- `wrangler deploy` — コードを Cloudflare のエッジ(=地理的に最寄りのデータセンター)に公開。
- GitHub 連携すれば main ブランチへの push で自動デプロイされ、手動実行が不要になる。
Pages Functions の基本
- リポジトリルートの `functions/` にファイルを置くだけ。ファイル名が URL パスになる。
- 例: `functions/api/hello.js` → `/api/hello` でアクセス可能。
- 動的パラメーターはブラケット記法 `[id].js` で表現。
- ビルド時にすべてのファイルが1つの Worker へ結合される(Functions bundle)。
REST API の実装
- `onRequestGet(context)` などの名前付きエクスポートで HTTP メソッドに対応。
- `Response.json(...)` で JSON レスポンスを返す。
よくある不具合の原因
- `functions/` がリポジトリルート以外にある — ビルドに含まれない。
- `_routes.json`(ルーティング制御ファイル)の `exclude` に `/api/*` が入っている — 静的ファイル扱いになる。
- Pages ダッシュボードで Functions が無効、または `wrangler.toml` が Workers 用設定になっている。
→ `functions/` はリポジトリルートに置き、ファイル名と URL パスを一致させれば、あとは Wrangler(または Git 連携)が自動で処理する。
Applied Sciences · Engineering
Cloudflare Wrangler and Pages Functions
Wrangler is Cloudflare's official CLI for developing and deploying Workers and Pages. Pages Functions extend a static site with serverless backend logic, bundled at build time into a single Worker.
What Wrangler does
- `wrangler dev` — starts a local dev server that mirrors production.
- `wrangler deploy` — publishes your code to Cloudflare's edge network.
- Git integration lets Pages auto-deploy on every push to main, so manual `wrangler deploy` is often unnecessary.
Pages Functions basics
- Place files in the repo-root `functions/` directory; file name = URL path.
- Example: `functions/api/hello.js` is accessible at `/api/hello`.
- Dynamic segments use bracket syntax: `[id].js`.
- At build time all files are bundled into one Worker (the Functions bundle).
Building a REST API
- Export named handlers like `onRequestGet(context)` to match HTTP methods.
- Return `Response.json(...)` for JSON responses.
Common failure causes
- `functions/` placed outside the repo root — files won't be included in the build.
- `_routes.json` `exclude` list contains `/api/*` — requests hit static files instead.
- Pages dashboard has Functions disabled, or `wrangler.toml` is written for Workers, not Pages.
→ Point `functions/` at the repo root, match file names to URL paths, and let Wrangler (or Git) handle the rest.
Applied Sciences · Engineering
Cloudflare Wrangler と Pages Functions
Wrangler(=Cloudflare公式CLI)は Workers / Pages の開発・デプロイを担うツール。Pages Functions は静的サイトにサーバーレスのバックエンド処理を追加する仕組みで、ビルド時に単一の Worker へバンドルされる。
Wrangler の役割
- `wrangler dev` — 本番に近い環境をローカルで再現するdev サーバーを起動。
- `wrangler deploy` — コードを Cloudflare のエッジ(=地理的に最寄りのデータセンター)に公開。
- GitHub 連携すれば main ブランチへの push で自動デプロイされ、手動実行が不要になる。
Pages Functions の基本
- リポジトリルートの `functions/` にファイルを置くだけ。ファイル名が URL パスになる。
- 例: `functions/api/hello.js` → `/api/hello` でアクセス可能。
- 動的パラメーターはブラケット記法 `[id].js` で表現。
- ビルド時にすべてのファイルが1つの Worker へ結合される(Functions bundle)。
REST API の実装
- `onRequestGet(context)` などの名前付きエクスポートで HTTP メソッドに対応。
- `Response.json(...)` で JSON レスポンスを返す。
よくある不具合の原因
- `functions/` がリポジトリルート以外にある — ビルドに含まれない。
- `_routes.json`(ルーティング制御ファイル)の `exclude` に `/api/*` が入っている — 静的ファイル扱いになる。
- Pages ダッシュボードで Functions が無効、または `wrangler.toml` が Workers 用設定になっている。
→ `functions/` はリポジトリルートに置き、ファイル名と URL パスを一致させれば、あとは Wrangler(または Git 連携)が自動で処理する。
Related notes
- Agentic Commerce — ACP and Visibility into Being 'Bought by AI'
- AI Search Evaluation: The 12 Metrics — Gateway
- AI Search Evaluation ①Citation Rate — How Many URLs Are Pulled In Per Answer
- AI Search Evaluation ②Source Diversity — How Unskewed the Cited Sources Are
- AI Search Evaluation ③Accuracy Score — How Often It Answers Factual Questions Correctly
- AI Search Evaluation ④Answer Length — How Many Characters It Returns to the User on Average