Wrangler
lastmod 2025-12-31created 2025-12-087 edits
Wrangler, the Cloudflare Developer Platform command-line interface (CLI), allows you to manage Worker projects.
Wrangler.json
wrangler.json is the central configuration file that holds all settings related to Cloudflare Workers deployment.
{
"$schema": "node_modules/wrangler/config-schema.json", // JSON 스키마 참조로, IDE에서 자동 완성과 유효성 검사 기능을 제공합니다.
"name": "cvp-app", // Cloudflare Workers에 배포될 애플리케이션의 고유한 이름입니다.
"main": "./src/worker/index.ts", // Workers 런타임의 진입점 파일 경로입니다. 백엔드 API 로직이 구현되어 있습니다.
"compatibility_date": "2025-10-08", // 사용할 Cloudflare Workers 런타임의 호환성 날짜입니다. 이 날짜는 Workers 런타임의 특정 버전과 기능 세트를 고정합니다.
"compatibility_flags": ["nodejs_compat"], // 활성화할 호환성 플래그 목록입니다. "nodejs_compat" 는 Node.js API와의 호환성을 제공하여 기존 Node.js 모듈을 사용할 수 있게 합니다.
"vars": { // 런타임에 Worker에 주입될 환경 변수들입니다.
"VITE_SUPABASE_URL": "https://xxx.supabase.co",
"VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY": "kkk"
},
"observability": { // 모니터링 및 로깅 설정입니다.
"enabled": true // Cloudflare의 관측 가능성(observability) 기능을 활성화합니다. 이를 통해 로그, 메트릭, 트레이싱 데이터를 수집할 수 있습니다.
},
"upload_source_maps": true, // 소스 맵을 Cloudflare에 업로드하여 프로덕션 환경에서 디버깅을 용이하게 합니다.
"assets": { // 정적 파일(HTML, CSS, JS 등) 서빙 설정입니다.
"directory": "./dist/client", // 정적 자산이 위치한 디렉토리 경로입니다. Vite 빌드 과정에서 생성되는 클라이언트 애플리케이션이 저장됩니다.
"not_found_handling": "single-page-application" // "single-page-application" 는 404 에러(존재하지 않는 경로 요청)때 index.html을 반환하여 SPA 라우팅을 지원합니다.
}
}
Notes
- The Supabase key in the environment variables is a public key, so it is safe to use on the client.
- The compatibility date should be updated only when new Workers features are needed.
- Uploading source maps is useful for debugging but can increase deployment time.
Related commands
-
npm run deploy: Deploy to Cloudflare Workers using this configuration -
npx wrangler tail: View real-time logs of the deployed Worker -
npm run cf-typegen: Generate TypeScript types for Cloudflare Workers -> creates theworker-configuration.d.tsfile.