{
  "slug": "combine-algolia-search-with-user-favorites",
  "title": "Combine Algolia Search Results with Supabase User Favorites",
  "metaTitle": "Combine Algolia Search Results with - RealComposer",
  "metaDescription": "Combine algolia search results with supabase user favorites. Merge Supabase and Algolia in one Frontend / Web call with parallel Worker steps.",
  "headline": "One edge call merges Supabase for Frontend / Web",
  "category": "aggregation",
  "categoryLabel": "Multi-API Aggregation",
  "urgency": 9,
  "clientPlatform": "Frontend / Web",
  "upstreamServices": [
    "Supabase",
    "Algolia"
  ],
  "searchIntentQuery": "combine algolia search results with supabase user favorites",
  "directAnswerSummary": "To combine algolia search results with supabase user favorites, configure parallel steps for Supabase and Algolia. Frontend / Web performs one authorized GET/POST to RealComposer and receives a merged payload.",
  "problem": {
    "title": "Serial Supabase and Algolia calls slow Frontend / Web pages",
    "explanation": "Each extra Supabase and Algolia hop adds hundreds of milliseconds and another OAuth refresh path your UI must manage.",
    "risks": [
      "One slow upstream blocking an entire page",
      "Partial failures leaving UI in inconsistent states",
      "Duplicate auth refresh logic per service"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Store upstream credentials in Secret Vault",
      "description": "Add SUPABASE_SERVICE_ROLE_KEY, ALGOLIA_API_KEY to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream."
    },
    {
      "stepNumber": 2,
      "title": "Target the real upstream URL",
      "description": "Use POST against https://{{secrets.SUPABASE_PROJECT_REF}}.supabase.co/rest/v1/{{query.table}}?{{query.filter}}. Allowed origins on the client token should match post pipelines set cache ttl to 0 because realcomposer only stores get responses at the edge."
    },
    {
      "stepNumber": 3,
      "title": "Call from Frontend / Web",
      "description": "Allowed origins on the token should list every Frontend / Web host that calls this URL.",
      "codeSnippet": "const res = await fetch('https://realcomposer.com/v1/workspace/combine-algolia-search-with-user-favorites', {\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n});"
    }
  ],
  "pipelineConfig": {
    "name": "Combine Algolia Search Results with Supabase User Favorites",
    "method": "POST",
    "cacheTtlSeconds": 0,
    "authMode": "client_token",
    "steps": [
      {
        "stepKey": "supabase",
        "upstreamUrlTemplate": "https://{{secrets.SUPABASE_PROJECT_REF}}.supabase.co/rest/v1/{{query.table}}?{{query.filter}}",
        "httpMethod": "GET",
        "headersTemplate": {
          "apikey": "{{secrets.SUPABASE_SERVICE_ROLE_KEY}}",
          "Authorization": "Bearer {{secrets.SUPABASE_SERVICE_ROLE_KEY}}"
        },
        "timeoutMs": 3000
      },
      {
        "stepKey": "algolia",
        "upstreamUrlTemplate": "https://{{secrets.ALGOLIA_APP_ID}}-dsn.algolia.net/1/indexes/{{query.index}}/query",
        "httpMethod": "POST",
        "headersTemplate": {
          "X-Algolia-API-Key": "{{secrets.ALGOLIA_API_KEY}}",
          "X-Algolia-Application-Id": "{{secrets.ALGOLIA_APP_ID}}",
          "Content-Type": "application/json"
        },
        "timeoutMs": 10000
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "supabase.rowId",
          "sourcePath": "0.id",
          "type": "string",
          "sourceStep": "supabase"
        },
        {
          "targetPath": "supabase.email",
          "sourcePath": "0.email",
          "type": "string",
          "sourceStep": "supabase"
        },
        {
          "targetPath": "algolia.hitCount",
          "sourcePath": "nbHits",
          "type": "number",
          "sourceStep": "algolia"
        },
        {
          "targetPath": "algolia.firstHit",
          "sourcePath": "hits.0.objectID",
          "type": "string",
          "sourceStep": "algolia"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "requestId": "req_combine-",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "combine-algolia-search-with-user-favorites"
    },
    "payload": {
      "id": "sample_id",
      "status": "active",
      "nested": {
        "tags": [
          "demo"
        ],
        "internal": true
      },
      "unused_blob": {
        "foo": "bar",
        "bar": "baz"
      }
    }
  },
  "sampleSlimmedOutput": {
    "supabase_rowId": "sample",
    "supabase_email": "sample",
    "algolia_hitCount": "sample",
    "algolia_firstHit": "sample"
  },
  "curlSnippet": "curl -X POST \"https://realcomposer.com/v1/workspace/combine-algolia-search-with-user-favorites\" \\\n  -H \"Authorization: Bearer rc_live_client_token\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"model\":\"example\"}'",
  "faqs": [
    {
      "question": "Can Frontend / Web call Supabase without holding the production key?",
      "answer": "Point Frontend / Web at /recipes/combine-algolia-search-with-user-favorites edge URL. RealComposer answers OPTIONS with Access-Control headers for allowed origins."
    },
    {
      "question": "Does POST traffic get cached?",
      "answer": "combine-algolia-search-with-user-favorites POST steps bypass caches.default even if cacheTtlSeconds is set in the dashboard."
    },
    {
      "question": "What happens if an upstream step times out?",
      "answer": "Upstream steps in combine-algolia-search-with-user-favorites honor timeoutMs and optional fallback JSON without leaking secrets."
    }
  ],
  "relatedRecipeSlugs": [
    "lightweight-api-gateway-jamstack",
    "combine-multiple-webhooks-into-one-payload",
    "merge-plaid-accounts-and-transactions"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/combine-algolia-search-with-user-favorites",
    "markdown": "https://realcomposer.com/recipes/combine-algolia-search-with-user-favorites.md",
    "json": "https://realcomposer.com/recipes/combine-algolia-search-with-user-favorites.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=combine-algolia-search-with-user-favorites&via=agent"
  }
}