跳到正文
文章中级

用 D1 构建评论 API

使用 D1 和 Hono 构建一个为静态博客存储和返回评论的 JSON API,并可选开启 CORS 支持。

最近更新
2026年10月12日
阅读原文

该介绍目前仅提供英文版本。

Add comments to a static blog without a server: create a D1 database, define a schema, and wire up GET and POST endpoints in a Hono app that read from and write to it.

What you’ll learn

  • Create a D1 database, schema and seed data
  • Initialize a Hono application in a Worker
  • Query and insert comments
  • Add CORS and deploy

Cloudflare products used

D1, Workers.

Follow the full, step-by-step tutorial in Cloudflare’s documentation.

继续学习