Overview
Complete configuration reference for the Serverless API Gateway. Covers servers, CORS, JWT authorizer, paths, service binding, and wrangler setup.
This guide explains how to configure the Serverless API Gateway with secure practices for different environments.
📁 Configuration Files
Core Configuration Files
src/api-config.json– Main API configurationsrc/api-config.schema.json– JSON schema for validationwrangler.toml– Cloudflare Workers configurationwrangler.auth.toml– Authentication-specific configuration (should be gitignored)docs/config-examples/*.json– Canonical, schema-validated examples used by tests/docs checks
Environment-Specific Configurations
You can keep separate config files per environment. If you do, validate each one against src/api-config.schema.json before deploy.
🔧 Configuration Templates
Basic API Configuration Template
{
"$schema": "./api-config.schema.json",
"title": "Your API Title",
"description": "Description of your API",
"cors": {
"allow_origins": ["https://your-domain.com"],
"allow_methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
"allow_headers": ["Content-Type", "Authorization"],
"expose_headers": ["*"],
"allow_credentials": true,
"max_age": 3600
},
"paths": [
{
"method": "GET",
"path": "/health",
"response": { "status": "ok", "version": "1.0.0" }
},
{
"method": "GET",
"path": "/api/v1/public",
"response": {
"message": "This is a public endpoint"
},
"auth": false
}
]
}Supabase Configuration Template
Auth0 Configuration Template
Wrangler Configuration Template
✅ Canonical Examples
Use these files as the source of truth for configuration examples:
serverlessapigateway/docs/config-examples/minimal.jsonserverlessapigateway/docs/config-examples/auth0.jsonserverlessapigateway/docs/config-examples/supabase.json
Configuration Sections
For detailed documentation on each configuration section, see:
Servers -- define upstream server aliases and URLs.
CORS -- configure cross-origin resource sharing policies.
Authorizer -- set up JWT-based authentication with HS256 or Auth0.
Paths -- define path-based API routing, methods, and integrations.
Service Binding -- bind API routes to Cloudflare Worker services.
Variable Mapping -- transform request headers and query parameters dynamically.
Last updated