Start With One Service

With a single service behind your API, handle authentication, limits and logging in that service. A gateway in front of it would be one more thing to run, for no gain. It earns its place when several services face the outside and each one starts solving the same problems separately.

Each team behind your public API wrote its own token validation, rate limiting and CORS handling. They mostly agree. Then a security review finds one service that checks the token’s signature but not its expiry, and revoked tokens have been working there for weeks.

An API gateway is the single front door that handles these cross-cutting jobs once: TLS, authentication, rate limits, routing and edge logging. It should stay thin. Business rules and resource-level authorisation belong in the services behind it. Below is what to put in the gateway, what to keep out, and how to run it so it does not become the single point of failure.

Signs you need a gateway
  • Every microservice re-implements JWT validation slightly differently
  • You have CORS bugs in three services with three different fixes
  • Your "rate limit" lives in 12 controllers and one of them has a typo
  • An LLM call accidentally cost $2,000 last month with no way to cap it