Files
anvil-hosting/functions
kappa f3dd6c8d5a feat: add terminal-style pricing table with region filtering
- Add dynamic pricing section with kubectl-style table UI
- Implement region tabs (Tokyo 1-3, Osaka 1-2, Seoul 1, Singapore 1)
- Integrate with existing /api/pricing endpoint
- Add localStorage caching with 1-hour TTL
- Apply terminal theme (Fira Code, GitHub Dark colors)
- Sort by price, filter by region

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 07:38:27 +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