Files
anvil-hosting/functions
kappa 758266d8cb refactor: app.js를 ES6 모듈로 분리
## 변경사항
- app.js (1370줄) → 7개 모듈 (1427줄)
- ES6 import/export 문법 사용
- Alpine.js 호환성 유지 (window 전역 노출)

## 모듈 구조
- js/config.js: 상수/설정 (WIZARD_CONFIG, PRICING_DATA, MOCK_*)
- js/api.js: ApiService
- js/utils.js: formatPrice, switchTab, ping 시뮬레이션
- js/wizard.js: 서버 추천 마법사 로직
- js/pricing.js: 가격표 컴포넌트
- js/dashboard.js: 대시보드 및 텔레그램 연동
- js/app.js: 메인 통합 (모든 모듈 import)

## HTML 변경
- <script type="module" src="js/app.js">로 변경
- 기존 기능 모두 정상 작동

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 12:59:54 +09:00
..

Cloudflare Pages Functions

API proxy endpoints for cloud-instances-api Worker.

Endpoints

Method Path Description
GET /api/health Health check
GET /api/instances Query VM instances with filters
POST /api/recommend Tech stack recommendations

Configuration

Environment Variables

Set in Cloudflare Pages dashboard or via CLI:

wrangler pages secret put WORKER_API_KEY

Required Secrets:

  • WORKER_API_KEY - API key for Worker authentication

Configured Variables (wrangler.toml):

  • WORKER_API_URL - Worker API base URL

Local Development

  1. Install dependencies:
npm install
  1. Create .env file:
WORKER_API_KEY=your-api-key-here
  1. Run local dev server:
npx wrangler pages dev . --port 8788

Deployment

wrangler pages deploy . --project-name anvil-hosting

CORS Configuration

All endpoints allow requests from:

  • Origin: https://hosting.anvil.it.com
  • Methods: GET, POST, OPTIONS
  • Headers: Content-Type

Architecture

Client Request
  ↓
/api/{endpoint} (Pages Function)
  ↓
functions/_shared/proxy.ts (CORS + Auth)
  ↓
cloud-instances-api.kappa-d8e.workers.dev (Worker)
  ↓
Response with CORS headers

Error Handling

All errors return JSON with CORS headers:

{
  "success": false,
  "error": "Error message",
  "details": "Optional error details"
}

Status codes:

  • 400 - Invalid request
  • 500 - Internal error
  • 503 - Worker API unavailable