githubEdit

Overview

This document provides detailed guidance on how to use the provided JSON configuration for setting up and managing your application's server, CORS (Cross-Origin Resource Sharing) settings, authorizati

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 configuration

  • src/api-config.schema.json – JSON schema for validation

  • wrangler.toml – Cloudflare Workers configuration

  • wrangler.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.json

  • serverlessapigateway/docs/config-examples/auth0.json

  • serverlessapigateway/docs/config-examples/supabase.json

Last updated