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.

Về trang lộ trình Track home

Phần 1: Deploy đầu tiên với Pages Part 1: First deploy with Pages · Bài 2/2 Lesson 2/2

Cấu hình build và output Configure build and output

Đặt build command (`npm run build`) và thư mục output (`dist`). Kiểm tra biến môi trường cho API URL. Set build command (`npm run build`) and output directory (`dist`). Check env vars for API URLs.

Các bước thực hiện Step-by-step

  1. Settings → Builds: `npm run build`, output `dist` (hoặc `build`). Settings → Builds: `npm run build`, output `dist` (or `build`).
  2. Thêm Environment variables: API_URL, PUBLIC_* cho build. Add environment variables: API_URL, PUBLIC_* for build.
  3. Node version ≥ 18 trong build config. Node version ≥ 18 in build config.
  4. Re-deploy sau khi sửa env — build log phải pass. Re-deploy after env changes — build log must pass.

Giải thích chi tiết Detailed explanation

Sai output directory là lỗi #1 Pages — Astro dùng `dist`, Create React App dùng `build`. Wrong output directory is the #1 Pages mistake — Astro uses `dist`, CRA uses `build`.

Lưu ý (best practices) Note (best practices)

Secret (API key, token) không được đặt trong wrangler config hay source — dùng `wrangler secret put`. Biến không nhạy cảm đặt trong `vars`; local dev dùng `.env` và thêm vào `.gitignore`. Secrets (API keys, tokens) must never appear in Wrangler config or source — use `wrangler secret put`. Non-sensitive config belongs in `vars`; use a `.env` file for local dev and add it to `.gitignore`.

Nguồn: Source: Workers Best Practices Workers Best Practices

Ví dụ triển khai (Cloudflare Resources) Deployment examples (Cloudflare Resources)

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.

Tutorial Tutorial Developer Platform Developer Platform

Thêm site Add a site

Tóm tắt thực hành: Thêm site trên Cloudflare. This tutorial uses Pulumi infrastructure as code (IaC) to familiarize yourself with the resource management lifecycle.

This tutorial uses Pulumi infrastructure as code (IaC) to familiarize yourself with the resource management lifecycle.

Tìm hiểu thêm Learn more
Tutorial Tutorial Developer Platform Developer Platform

Thêm mới AI Models vào Playground (Part 2) Add New AI Models to your Playground (Part 2)

Tóm tắt thực hành: Thêm mới AI Models vào Playground (Part 2) trên Workers AI. In part 2, Kristian expands upon the existing environment built in part 1, by showing you how to integrate new AI models and introduce new parameters that allow you to customize h…

In part 2, Kristian expands upon the existing environment built in part 1, by showing you how to integrate new AI models and introduce new parameters that allow you to customize how images are generated.

Tìm hiểu thêm Learn more

Xem thêm ví dụ trong lộ trình → More examples in this path →

Tài liệu Cloudflare Developers Cloudflare Developer docs

Sản phẩm liên quan Related products

Học xong hoặc muốn đổi hướng? Finished or want a different path?

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.

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