{
  "slug": "fix-retool-cors-error",
  "title": "Retool CORS Error Connecting to External REST API",
  "metaTitle": "Retool CORS Error Connecting to - RealComposer",
  "metaDescription": "Retool cors error connecting to external rest api. Retool CORS fix for REST API via RealComposer OPTIONS plus vault headers.",
  "headline": "Low-code REST API BFF for Retool",
  "category": "ecosystem",
  "categoryLabel": "Platforms & Frameworks",
  "urgency": 9,
  "clientPlatform": "Retool",
  "upstreamServices": [
    "REST API"
  ],
  "searchIntentQuery": "retool cors error connecting to external rest api",
  "directAnswerSummary": "Retool browsers cannot call https://jsonplaceholder.typicode.com/users/{{query.userId}} directly because of CORS and hidden credentials. RealComposer responds to OPTIONS and proxies authorized traffic.",
  "problem": {
    "title": "Retool cannot attach secret headers to REST API",
    "explanation": "Retool runs in the browser or a sandbox without a secret store. REST API rejects unsigned browser origins or requires server-only headers.",
    "risks": [
      "Proxy hacks that break when vendors tighten CSP",
      "Zapier-only workarounds adding cost and latency",
      "Guest users seeing failed network requests in demos"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Add vault secrets for this pipeline",
      "description": "Store API_BEARER_TOKEN in the vault. Retool never embeds the raw secret, only a revocable rc_live_ client token."
    },
    {
      "stepNumber": 2,
      "title": "Configure upstream steps and output mapping",
      "description": "Configure headersTemplate to inject vault secrets, target https://jsonplaceholder.typicode.com/users/{{query.userId}}, and Add output mapping fields that mirror the JSON contract your screen already expects."
    },
    {
      "stepNumber": 3,
      "title": "Query from Retool",
      "description": "Allowed origins on the token should list every Retool host that calls this URL.",
      "codeSnippet": "// REST resource or JS query\nconst rows = await fetch('https://realcomposer.com/v1/workspace/fix-retool-cors-error', {\n  headers: { Authorization: 'Bearer rc_live_token' }\n}).then(r => r.json());"
    }
  ],
  "pipelineConfig": {
    "name": "Retool CORS Error Connecting to External REST API",
    "method": "GET",
    "cacheTtlSeconds": 0,
    "authMode": "client_token",
    "steps": [
      {
        "stepKey": "upstream",
        "upstreamUrlTemplate": "https://jsonplaceholder.typicode.com/users/{{query.userId}}",
        "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_fix-reto",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "fix-retool-cors-error"
    },
    "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/fix-retool-cors-error\" \\\n  -H \"Authorization: Bearer rc_live_client_token\"",
  "faqs": [
    {
      "question": "What should Retool store instead of REST API secrets?",
      "answer": "Log request IDs for fix-retool-cors-error, not raw REST API payloads, because upstream bodies may include PII."
    },
    {
      "question": "How do I forward JSON bodies to POST upstreams?",
      "answer": "fix-retool-cors-error keeps cache TTL at 0 because it uses POST upstream calls or per-user responses. Add ids to query strings before enabling GET cache."
    },
    {
      "question": "How do I rotate upstream credentials?",
      "answer": "Upstream steps in fix-retool-cors-error honor timeoutMs and optional fallback JSON without leaking secrets."
    }
  ],
  "relatedRecipeSlugs": [
    "rest-api-edge-cdn-caching-guide",
    "trim-sendgrid-activity-api",
    "merge-plaid-accounts-and-transactions"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/fix-retool-cors-error",
    "markdown": "https://realcomposer.com/recipes/fix-retool-cors-error.md",
    "json": "https://realcomposer.com/recipes/fix-retool-cors-error.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=fix-retool-cors-error&via=agent"
  }
}