Build an API for your front end using Pages Functions
/pages/tutorials/build-an-api-with-pages-functions
Mở tutorial / guide ↗ Open tutorial / guide ↗Phần 2: API trên edge Part 2: APIs on the edge · Bài 1/2 Lesson 1/2
Đặt handler trong `functions/` để xử lý form, webhook, proxy nhẹ. Phù hợp logic gắn với site Pages. Put handlers in `functions/` for forms, webhooks, light proxying. Good for logic tied to your Pages site.
Pages Functions chạy trên Workers runtime — API gắn với site, không cần server riêng. Pages Functions run on the Workers runtime — APIs colocated with your site, no separate server.
Luôn `await` hoặc `ctx.waitUntil()` mọi Promise — nếu không, Worker có thể kết thúc trước khi tác vụ nền hoàn tất. Always `await` or use `ctx.waitUntil()` for every Promise — otherwise the Worker may terminate before background work completes.
Nguồn: Source: Workers Best Practices Workers Best Practices ↗
Tutorial, solution guide và reference từ developers.cloudflare.com/resources ↗ — gợi ý theo chủ đề bài học. Tutorials, solution guides, and reference docs from developers.cloudflare.com/resources ↗ — matched to this lesson topic.
/pages/tutorials/build-an-api-with-pages-functions
Mở tutorial / guide ↗ Open tutorial / guide ↗/pages/tutorials/add-a-react-form-with-formspree
Mở tutorial / guide ↗ Open tutorial / guide ↗/pulumi/tutorial/add-site
Mở tutorial / guide ↗ Open tutorial / guide ↗/pages/tutorials/add-an-html-form-with-formspree
Mở tutorial / guide ↗ Open tutorial / guide ↗Fullstack applications Fullstack applications
Ví dụ fullstack trên Developer Platform — Workers/Pages, storage và AI services trong một kiến trúc thực tế. A practical example of how these services come together in a real fullstack application architecture.
Thuật ngữ: Concepts: Workers · Pages · D1 · R2 · KV · Durable Objects
Sơ đồ chính thức ↗ Official diagram ↗ · Serverless Serverless
Serverless global APIs Serverless global APIs
An example architecture of a serverless API on Cloudflare and aims to illustrate how different compute and data products could interact with each other. An example architecture of a serverless API on Cloudflare and aims to illustrate how different compute and data products could interact with each other.
Thuật ngữ: Concepts: Workers · D1 · R2 · Global API · Edge compute
Sơ đồ chính thức ↗ Official diagram ↗ · Serverless Serverless