⚡
Serverless API Gateway Documentation
Creator
⚡
Serverless API Gateway Documentation
  • Serverless API Gateway
  • Getting Started
    • Introduction
    • Cost
  • Configuration
    • Overview
    • Servers
    • Service Binding
    • Paths
      • Add and Remove Prefix
    • Authorizer
    • CORS
    • Variable Mapping
      • Priority Variables
    • Integrations
      • Auth0
  • Deployment
    • Wrangler
    • GitHub Actions
  • Glossary
    • A
      • API (Application Programming Interface)
      • API Endpoint
      • API Gateway
      • API Key
      • API Rate Limiting
      • Asynchronous Operation
      • Authentication
      • Authorization
    • B
      • Backend as a Service (BaaS)
      • Blueprint
    • C
      • Cache
      • CDN (Content Delivery Network)
      • CI/CD (Continuous Integration/Continuous Deployment)
      • Client
      • Client-Side Rendering (CSR)
      • Cloud Service Provider (CSP)
      • Cluster
      • Container
      • Continuous Delivery
      • Continuous Integration
      • Cron Job
    • D
      • Data Lake
      • Data Warehousing
      • Database
      • Deployment
      • DevOps
      • Distributed System
      • DNS (Domain Name System)
      • Docker
      • Domain
    • E
      • Edge Computing
      • Elasticity
      • Endpoint Security
      • Environment Variables
      • Event-Driven Architecture
    • F
      • Fault Tolerance
      • Firewall
      • Function as a Service (FaaS)
    • G
      • Git
      • GraphQL
    • H
      • Hashing
      • High Availability (HA)
      • HTTP (Hypertext Transfer Protocol)
      • HTTPS (Hypertext Transfer Protocol Secure)
    • I
      • Infrastructure as a Service (IaaS)
    • J
      • JSON (JavaScript Object Notation)
    • K
      • Kubernetes
    • L
      • Latency
      • Load Balancer
      • Logging
    • M
      • Microservices
      • Middleware
      • Migration
      • Mocking
      • Monolithic Architecture
      • Multi-Cloud
    • N
      • Network Protocol
    • O
      • OAuth
      • Object Storage
      • Orchestration
    • P
      • PaaS (Platform as a Service)
      • Payload
      • Performance Testing
      • Plugin
      • Private Cloud
      • Public Cloud
      • Pull Request
    • Q
      • Query Language
      • Query Parameters
      • Queue
    • R
      • Rate Limiting
      • Real-Time Processing
      • Redundancy
      • Refactoring
      • Regression Testing
      • Repository
      • REST (Representational State Transfer)
      • Rollback
    • S
      • SaaS (Software as a Service)
      • Scalability
      • Schema
      • SDK (Software Development Kit)
      • Service Mesh
      • Session
      • SLA (Service Level Agreement)
      • SOAP (Simple Object Access Protocol)
      • State
      • Stateless
      • Static Site Generator
      • Storage
      • Stress Testing
      • Swagger (OpenAPI)
Powered by GitBook
On this page
  • Introduction
  • Goals and Motivation
  • Where It Fits in Your Architecture
  • Key Features at a Glance
  • How It Differs from Traditional Solutions
Edit on GitHub

Serverless API Gateway

Welcome to the Serverless API Gateway, an innovative tool designed to streamline your API management tasks using the powerful capabilities of Cloudflare Workers.

Introduction

The Serverless API Gateway is a globally distributed, Cloudflare Workers–powered solution that simplifies how you manage and secure your APIs. Whether you’re stitching together multiple microservices or transforming requests on the fly, this gateway brings crucial features—routing, CORS, authentication, service binding, and more—into a single, lightweight tool.

Goals and Motivation

Modern applications rely on APIs for data exchange, yet securing and organizing these APIs can be a headache. Traditional reverse proxies or monolithic API gateways often require complex setups, dedicated servers, or costly managed solutions. The Serverless API Gateway emerged to address these pain points:

  • Security at the Edge: Enforce JWT-based authentication or integrate with Auth0, ensuring only valid requests pass through.

  • Simple, Config-Driven Routing: Avoid sprawling or duplicated routing logic. Define paths in a JSON file and let the gateway do the heavy lifting.

  • Global Reach, No Servers: Because it’s built on Cloudflare Workers, your APIs are served from Cloudflare’s edge network—no server upkeep required.

  • Adaptable for Microservices: Tightly couple front-end routes to multiple backends or Worker services in one place, reducing architectural complexity.

  • Cost-Effective: Only pay for the Cloudflare Workers usage (with a generous free tier), bypassing the overhead of maintaining dedicated gateways.

Where It Fits in Your Architecture

In a typical microservices environment, each service (e.g., Users, Payments, Notifications) might be deployed separately. The Serverless API Gateway sits in front of these services:

[ Client / Frontend ]
           |  (API calls)
           v
  ┌───────────────────────────────────┐
  │  Serverless API Gateway (Worker) │
  │   - Routing & Path Matching      │
  │   - CORS & Auth                  │
  │   - Request Transformation       │
  │   - Service Binding (Workers)    │
  └───────────────────────────────────┘
           |
           v
 [ Users Service ]   [ Payment Service ]   [ External API ]  ...
  • Client: Sends HTTP requests to a single gateway URL (e.g., my-api.example.com).

  • Gateway (this project): Matches each request to a route, applies JWT or Auth0 checks, transforms headers/queries if needed, and proxies/calls the correct backend.

  • Backend Services: Focus solely on business logic—relying on the gateway to handle cross-cutting concerns like authentication and cross-origin allowances.

By centralizing these features at the Worker layer, you can unify your security model and reduce the boilerplate in downstream microservices.

Key Features at a Glance

  • JS Workers: Write serverless JavaScript Workers that intercept and modify your API requests and responses on the fly.

    • JWT: Validate tokens using a shared secret (HS256) or RS256 with Auth0’s JWKS.

    • Supabase OTP: Optionally integrate phone/email OTP flows if you’re using Supabase.

    • Auth0 Authentication: This service offers reliable identity management by simplifying user authentication. It supports multiple providers, ensuring secure, easy integration for developers and users.

How It Differs from Traditional Solutions

  • No Dedicated Infrastructure: Everything runs on Cloudflare’s edge, eliminating the typical overhead of provisioning servers or VMs for a gateway.

  • Fine-Grained Control at the Edge: Because it’s serverless code, you can place custom logic right where requests arrive, with extremely low latency.

  • Pay-as-You-Go: Unlike many managed API gateways that charge flat monthly fees or have complex pricing tiers, this leverages Cloudflare’s usage-based model (often free for small workloads).

  • Easier Microservice Integration: You can tie multiple backends or even other Cloudflare Workers to a single, config-driven gateway, rather than chaining or deploying separate proxies.

NextIntroduction

Last updated 3 months ago

: Simplify your API architecture with flexible path and method-based routing for directing traffic to the appropriate endpoints.

: Bind your API to a service as Workers, so you can use the Workers capabilities within your API.

: Manage cross-origin resource sharing settings with ease, ensuring your APIs can securely handle requests from different origins.

: Secure your APIs by implementing JSON Web Token (JWT) based authentication to validate and manage user access efficiently.

: Map variables from sources to destinations, allowing you to easily transform your data.

Routing (Path and Method)
Service Binding
CORS
Authentication (JWT)
Variable Mapping