{
  "slug": "reverse-proxy-api-key-protection",
  "title": "Reverse Proxy for Third Party API Key Protection",
  "metaTitle": "Reverse Proxy for Third Party API - RealComposer",
  "metaDescription": "Reverse proxy for third party api key protection. Keep REST API keys in RealComposer Vault; Frontend / Web uses rc_live_ tokens only.",
  "headline": "Vault-backed REST API proxy tuned for Frontend / Web",
  "category": "security",
  "categoryLabel": "Security & Secret Vault",
  "urgency": 8,
  "clientPlatform": "Frontend / Web",
  "upstreamServices": [
    "REST API"
  ],
  "searchIntentQuery": "reverse proxy for third party api key protection",
  "directAnswerSummary": "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.",
  "problem": {
    "title": "REST API keys in Frontend / Web network tabs",
    "explanation": "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.",
    "risks": [
      "Shared Frontend / Web projects revealing REST API tokens",
      "Sudden REST API quota burn from scripted abuse",
      "Inability to rotate keys without redeploying clients"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Store upstream credentials in Secret Vault",
      "description": "Add API_BEARER_TOKEN to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream."
    },
    {
      "stepNumber": 2,
      "title": "Set headers, mapping, and cache TTL",
      "description": "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)."
    },
    {
      "stepNumber": 3,
      "title": "Call from Frontend / Web",
      "description": "Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.",
      "codeSnippet": "const res = await fetch('https://realcomposer.com/v1/workspace/reverse-proxy-api-key-protection', {\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n});"
    }
  ],
  "pipelineConfig": {
    "name": "Reverse Proxy for Third Party API Key Protection",
    "method": "GET",
    "cacheTtlSeconds": 0,
    "authMode": "client_token",
    "steps": [
      {
        "stepKey": "upstream",
        "upstreamUrlTemplate": "https://{{secrets.API_HOST}}/status",
        "httpMethod": "GET",
        "headersTemplate": {
          "Authorization": "Bearer {{secrets.API_BEARER_TOKEN}}"
        },
        "timeoutMs": 3000
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "userId",
          "sourcePath": "id",
          "type": "number",
          "sourceStep": "upstream"
        },
        {
          "targetPath": "name",
          "sourcePath": "name",
          "type": "string",
          "sourceStep": "upstream"
        },
        {
          "targetPath": "email",
          "sourcePath": "email",
          "type": "string",
          "sourceStep": "upstream"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "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"
      }
    }
  },
  "sampleSlimmedOutput": {
    "userId": "sample",
    "name": "sample",
    "email": "sample"
  },
  "curlSnippet": "curl -X GET \"https://realcomposer.com/v1/workspace/reverse-proxy-api-key-protection\" \\\n  -H \"Authorization: Bearer rc_live_client_token\"",
  "faqs": [
    {
      "question": "What should Frontend / Web store instead of REST API secrets?",
      "answer": "Log request IDs for reverse-proxy-api-key-protection, not raw REST API payloads, because upstream bodies may include PII."
    },
    {
      "question": "How do I forward JSON bodies to POST upstreams?",
      "answer": "Cache key for reverse-proxy-api-key-protection: internal edge-cache path plus sorted query. Identical params hit; vary userId per user."
    },
    {
      "question": "Can I restrict which domains call this pipeline?",
      "answer": "Allowed origins on the reverse-proxy-api-key-protection client token restrict which domains may call the edge URL."
    }
  ],
  "relatedRecipeSlugs": [
    "cache-weather-api-edge",
    "avoid-stripe-api-rate-limit",
    "cache-airtable-avoid-rate-limits"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/reverse-proxy-api-key-protection",
    "markdown": "https://realcomposer.com/recipes/reverse-proxy-api-key-protection.md",
    "json": "https://realcomposer.com/recipes/reverse-proxy-api-key-protection.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=reverse-proxy-api-key-protection&via=agent"
  }
}