Skip to main content
Frontline’s local-dev mode runs the gateway on your machine with routes and policies from a TOML file. This example puts it in front of traefik/whoami, an HTTP echo service that returns request headers. No application code is needed. A valid API key reaches the echo service with an X-Unkey-Principal header. Frontline rejects missing or invalid keys before they reach the service.
Use this example for local development only. The echo response includes the API key’s Authorization header and principal metadata. Use development keys and keep .env out of version control.

Prerequisites

You need Docker Compose, a keyspace, a root key with permission to verify keys in that keyspace, and an API key from that keyspace.

Configure the containers

Create these three files in the same directory. Replace the root key and keyspace ID in .env with your development values.
Only Frontline is exposed to your host, on loopback port 3000. The echo service is internal to the Compose network. Frontline uses https://api.unkey.com to verify keys by default. The authentication policy deducts one credit from keys with limited usage for each successful request. Keys with unlimited usage are unaffected.

Start the gateway

Run these commands from the directory containing the three files:

Inspect the forwarded headers

Set your API key in the terminal, then send a request through Frontline:
The response includes X-Unkey-Principal, X-Forwarded-Host, and X-Forwarded-Proto: http. Header capitalization can differ. The principal’s subject is the key’s identity external ID, or its key ID if it has no identity. Send the same request without a key to check rejection:
Expect HTTP 401 instead of an echo response. To use your own application, replace the api service and set upstream to its Compose service name and listening port. Keep its port internal so requests cannot bypass Frontline.

Stop the example

Remove both containers and their Compose network:

Next steps

The principal header

Read every field and when it is omitted.

Gateway policies

Add authentication, rate limits, and other rules to your app.
Last modified on October 6, 2026