Reverse Proxy for Third Party API Key Protection
Vault-backed REST API proxy tuned for Frontend / Web
Never place API_BEARER_TOKEN inside Frontend / Web source. RealComposer injects them when calling https://{{secrets.API_HOST}}/status, so browsers see only a client token.
REST API keys in Frontend / Web network tabs
Frontend / Web ships code or scripts to end-user devices. Any REST API bearer token in those bundles can be copied from DevTools, proxies, or repackaged apps.
- Shared Frontend / Web projects revealing REST API tokens
- Sudden REST API quota burn from scripted abuse
- Inability to rotate keys without redeploying clients
How RealComposer Solves This at the Edge
Store upstream credentials in Secret Vault
Add API_BEARER_TOKEN to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream.
Set headers, mapping, and cache TTL
Point step upstream at https://{{secrets.API_HOST}}/status with GET. Add output mapping fields that mirror the JSON contract your screen already expects. Leave cache TTL at 0 when each response is user-specific (include userId or record id in query params before enabling cache).
Call from Frontend / Web
Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.
const res = await fetch('https://realcomposer.com/v1/workspace/reverse-proxy-api-key-protection', {
headers: { Authorization: 'Bearer rc_live_your_token' }
});
{
"requestId": "req_reverse-",
"upstreamLatencyMs": 142,
"audit": {
"region": "edge",
"trace": "reverse-proxy-api-key-protection"
},
"payload": {
"id": "sample_id",
"status": "active",
"nested": {
"tags": [
"demo"
],
"internal": true
},
"unused_blob": {
"foo": "bar",
"bar": "baz"
}
}
}
{
"userId": "sample",
"name": "sample",
"email": "sample"
}
Recipe Specs
- HTTP method
- GET
- Upstream calls
- 1
- Edge cache TTL
- No caching
- Client auth
- Restricted client token
- Mapped output fields
- 3
- Payload
- 251 B to 52 B (-79%)
curl -X GET "https://realcomposer.com/v1/workspace/reverse-proxy-api-key-protection" \ -H "Authorization: Bearer rc_live_client_token"
Developer Questions & Troubleshooting
What should Frontend / Web store instead of REST API secrets?
Log request IDs for reverse-proxy-api-key-protection, not raw REST API payloads, because upstream bodies may include PII.
How do I forward JSON bodies to POST upstreams?
Cache key for reverse-proxy-api-key-protection: internal edge-cache path plus sorted query. Identical params hit; vary userId per user.
Can I restrict which domains call this pipeline?
Allowed origins on the reverse-proxy-api-key-protection client token restrict which domains may call the edge URL.
Sources & Definitions Used in This Answer
- DefinitionAPI Proxy
- DefinitionForward Proxy
- DefinitionAPI Key
- DefinitionMutual TLS (mTLS)
- DefinitionWeb Application Firewall (WAF)
- DefinitionCSRF Protection
- DefinitionEncryption in Transit
- DefinitionIP Allowlisting
- DefinitionOWASP API Security
- DefinitionAPI Injection
- DefinitionHTTP Security Headers
- DefinitionHTTP Strict Transport Security (HSTS)
- DefinitionOpaque Access Token
- DefinitionMFA for API Access
- DefinitionReplay Attack Prevention
- DefinitionCryptographic Nonce
- DefinitionConstant-Time Comparison
- DefinitionAPI Security Testing
- DefinitionPermissions Policy
- DefinitionAPI Supply Chain Risk
- DefinitionBreak-Glass Access
- DefinitionClient Certificates
- Stack guideWeb Frontends safe & unsafe practices
- Stack guideREST APIs safe & unsafe practices
- Official docsWeb Frontends documentation
- Official docsREST APIs documentation
Deploy this Frontend / Web + REST API Recipe
Clone this pre-configured pipeline into your RealComposer workspace in one click. We pre-populate upstream URLs, headers, and mapping rules.