Aggregate contentful content with algolia search
Headless site search with CMS hits
Algolia search results enriched with Contentful entry fields at edge. For "aggregate contentful content with algolia search", store CONTENTFUL_ACCESS_TOKEN, ALGOLIA_API_KEY in Secret Vault, call https://cdn.contentful.com/spaces/{{query.spaceId}}/entries from a Worker, and let Next.js / React hit only https://realcomposer.com/v1/workspace/aggregate-contentful-with-algolia-search with an rc_live_ client token. POST upstream calls are not stored in caches.default; clients must send JSON bodies and headers forward unchanged.
Waterfall latency from multiple Contentful and Algolia requests
Next.js / React widgets often await Contentful and Algolia sequentially, multiplying TLS handshakes on cellular networks and amplifying failure rates.
- Race conditions between parallel manual fetches
- Higher mobile data usage from redundant JSON
- Timeouts when any upstream exceeds cellular RTT
How RealComposer Solves This at the Edge
Store upstream credentials in Secret Vault
Create CONTENTFUL_ACCESS_TOKEN, ALGOLIA_API_KEY vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders.
Configure upstream steps and output mapping
Point step contentful at https://cdn.contentful.com/spaces/{{query.spaceId}}/entries with POST. Add output mapping fields that mirror the JSON contract your screen already expects. POST pipelines set cache TTL to 0 because RealComposer only stores GET responses at the edge.
Call from Next.js / React
Allowed origins on the token should list every Next.js / React host that calls this URL.
// app/api route or client component
const res = await fetch('https://realcomposer.com/v1/workspace/aggregate-contentful-with-algolia-search', {
cache: 'no-store',
headers: { Authorization: 'Bearer rc_live_your_token' }
});
{
"requestId": "req_aggregat",
"upstreamLatencyMs": 142,
"audit": {
"region": "edge",
"trace": "aggregate-contentful-with-algolia-search"
},
"payload": {
"id": "sample_id",
"status": "active",
"nested": {
"tags": [
"demo"
],
"internal": true
},
"unused_blob": {
"foo": "bar",
"bar": "baz"
}
}
}
{
"contentful_entryId": "sample",
"contentful_title": "sample",
"algolia_hitCount": "sample",
"algolia_firstHit": "sample"
}
Recipe Specs
- HTTP method
- POST
- Upstream calls
- 2
- Edge cache TTL
- No caching
- Client auth
- Restricted client token
- Mapped output fields
- 4
- Payload
- 259 B to 115 B (-56%)
curl -X POST "https://realcomposer.com/v1/workspace/aggregate-contentful-with-algolia-search" \
-H "Authorization: Bearer rc_live_client_token" \
-H "Content-Type: application/json" \
-d '{"model":"example"}'Developer Questions & Troubleshooting
Is it safe to log Contentful responses in Next.js / React?
Use scoped tokens where the vendor allows them on aggregate-contentful-with-algolia-search. Admin keys stay {{secrets.*}} references only.
When does edge caching apply to this recipe?
aggregate-contentful-with-algolia-search keeps cache TTL at 0 because it uses POST upstream calls or per-user responses. Add ids to query strings before enabling GET cache.
Can I restrict which domains call this pipeline?
Allowed origins on the aggregate-contentful-with-algolia-search client token restrict which domains may call the edge URL.
Sources & Definitions Used in This Answer
Deploy this Next.js / React + Contentful, Algolia Recipe
Clone this pre-configured pipeline into your RealComposer workspace in one click. We pre-populate upstream URLs, headers, and mapping rules.