{
  "slug": "mobile-friendly-api-from-legacy-rest",
  "title": "How to Create Mobile Friendly API from Legacy REST Service",
  "metaTitle": "Create Mobile Friendly API from - RealComposer",
  "metaDescription": "How to create mobile friendly api from legacy rest service. Mobile App (iOS & Android) CORS fix for REST API via RealComposer OPTIONS plus vault headers.",
  "headline": "REST API without CORS hacks in Mobile App (iOS & Android)",
  "category": "ecosystem",
  "categoryLabel": "Platforms & Frameworks",
  "urgency": 8,
  "clientPlatform": "Mobile App (iOS & Android)",
  "upstreamServices": [
    "REST API"
  ],
  "searchIntentQuery": "how to create mobile friendly api from legacy rest service",
  "directAnswerSummary": "Fix \"how to create mobile friendly api from legacy rest service\" by pointing Mobile App (iOS & Android) at RealComposer. Vault secrets authenticate https://jsonplaceholder.typicode.com/users/{{query.userId}}; client tokens gate your public URL.",
  "problem": {
    "title": "CORS blocks REST API in Mobile App (iOS & Android)",
    "explanation": "Low-code Mobile App (iOS & Android) tools expose connector tokens in shared workspaces, so REST API credentials leak to every editor.",
    "risks": [
      "Browser console CORS errors blocking launches",
      "Editors pasting secrets into reusable components",
      "Inability to test locally without disabling security"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Add vault secrets for this pipeline",
      "description": "Store API_BEARER_TOKEN in the vault. Mobile App (iOS & Android) never embeds the raw secret, only a revocable rc_live_ client token."
    },
    {
      "stepNumber": 2,
      "title": "Set headers, mapping, and cache TTL",
      "description": "Point step upstream at https://jsonplaceholder.typicode.com/users/{{query.userId}} 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 Mobile App (iOS & Android)",
      "description": "Call https://realcomposer.com/v1/workspace/mobile-friendly-api-from-legacy-rest with a restricted rc_live_ client token. Mobile App (iOS & Android) never sends upstream secrets.",
      "codeSnippet": "let url = URL(string: \"https://realcomposer.com/v1/workspace/mobile-friendly-api-from-legacy-rest\")!\nvar request = URLRequest(url: url)\nrequest.addValue(\"Bearer rc_live_token\", forHTTPHeaderField: \"Authorization\")"
    }
  ],
  "pipelineConfig": {
    "name": "How to Create Mobile Friendly API from Legacy REST Service",
    "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_mobile-f",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "mobile-friendly-api-from-legacy-rest"
    },
    "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/mobile-friendly-api-from-legacy-rest\" \\\n  -H \"Authorization: Bearer rc_live_client_token\"",
  "faqs": [
    {
      "question": "Is it safe to log REST API responses in Mobile App (iOS & Android)?",
      "answer": "Yes for mobile-friendly-api-from-legacy-rest. Ship only an rc_live_ client token in Mobile App (iOS & Android); RealComposer injects API_BEARER_TOKEN on https://jsonplaceholder.typicode.com/users/{{query.userId}}."
    },
    {
      "question": "Will Anthropic or Linear prompt bodies be rewritten?",
      "answer": "mobile-friendly-api-from-legacy-rest vault headers attach server-side, but Anthropic or OpenAI model and messages must come from the client body."
    },
    {
      "question": "What happens if an upstream step times out?",
      "answer": "Rotate vault secrets for mobile-friendly-api-from-legacy-rest anytime; clients keep the same rc_live_ token."
    }
  ],
  "relatedRecipeSlugs": [
    "best-api-gateway-react-native",
    "supabase-edge-functions-alternative",
    "flutterflow-backend-for-frontend-tutorial"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/mobile-friendly-api-from-legacy-rest",
    "markdown": "https://realcomposer.com/recipes/mobile-friendly-api-from-legacy-rest.md",
    "json": "https://realcomposer.com/recipes/mobile-friendly-api-from-legacy-rest.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=mobile-friendly-api-from-legacy-rest&via=agent"
  }
}