Build an API for your front end using Pages Functions
/pages/tutorials/build-an-api-with-pages-functions
Mở tutorial / guide ↗ Open tutorial / guide ↗Lộ trình đang học Current learning path
Developer Platform Developer Platform
Build và deploy apps trên Cloudflare. Build and deploy apps on Cloudflare.
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 ↗
Ví dụ chính thức từ Cloudflare Resources — gợi ý theo chủ đề bài học trong lộ trình này. Official examples from Cloudflare Resources — matched to this lesson within this path.
/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 ↗Xem thêm ví dụ trong lộ trình → More examples in this path →
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
Ba lộ trình độc lập — mỗi lộ trình chỉ gồm bài học và tài liệu trong phạm vi đó. Chọn lộ trình khác khi sẵn sàng, không cần học song song. Three independent paths — each includes only lessons and materials for that scope. Switch when you are ready; no need to study paths in parallel.
Bảo vệ và tăng tốc website, application và API Protect and accelerate websites, applications, and APIs
Vào lộ trình này → Enter this path →Bảo vệ users, access, SaaS và mạng doanh nghiệp Secure users, access, SaaS, and corporate networks
Vào lộ trình này → Enter this path →Chưa chắc — làm bài chọn lộ trình Not sure — use the path selector · So sánh cả ba lộ trình Compare all three paths