Cloudflare Pages配置流程
- 登录Cloudflare控制台
- 创建新项目 → 选择Git仓库
- 构建设置:
# 构建命令
npm run build
# 输出目录
dist
Astro项目适配
// astro.config.mjs
export default defineConfig({
adapter: cloudflare(),
output: 'server'
});
wrangler.toml示例
name = "astro-blog"
account_id = "YOUR_ACCOUNT_ID"
compatibility_date = "2024-06-01"
[env.production]
variables = {
PUBLIC_API_URL = "https://api.example.com"
}
部署注意事项
- 开启\u200c
自动HTTPS重定向
- 配置\u200c
缓存清除策略
- 绑定自定义域名后等待DNS生效