- 가격표 섹션을 페이지 하단에서 히어로 바로 아래로 이동 - 상단 패딩 축소 (py-24 → pt-12 pb-24) - 서브탭(서울/글로벌 타입) 스타일을 메인탭과 동일하게 통일 - Pages Functions API 프록시 추가 (functions/) - wrangler.toml 및 TypeScript 설정 추가 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
89 lines
1.5 KiB
Markdown
89 lines
1.5 KiB
Markdown
# 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:
|
|
|
|
```bash
|
|
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:
|
|
```bash
|
|
npm install
|
|
```
|
|
|
|
2. Create `.env` file:
|
|
```bash
|
|
WORKER_API_KEY=your-api-key-here
|
|
```
|
|
|
|
3. Run local dev server:
|
|
```bash
|
|
npx wrangler pages dev . --port 8788
|
|
```
|
|
|
|
## Deployment
|
|
|
|
```bash
|
|
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:
|
|
|
|
```json
|
|
{
|
|
"success": false,
|
|
"error": "Error message",
|
|
"details": "Optional error details"
|
|
}
|
|
```
|
|
|
|
Status codes:
|
|
- `400` - Invalid request
|
|
- `500` - Internal error
|
|
- `503` - Worker API unavailable
|