Call Algolia Write API from Client without Master Key
Algolia secrets stay out of Frontend / Web bundles
Frontend / Web cannot safely store Algolia production keys. Vault-bound headers reach https://{{secrets.ALGOLIA_APP_ID}}-dsn.algolia.net/1/indexes/{{query.index}}/query on Workers while apps call your algolia-write-api-secure-proxy edge URL.
Why Frontend / Web leaks Algolia credentials
Attackers routinely extract Algolia secrets from Frontend / Web builds. Direct browser calls also expose internal error payloads with hostnames.
- Production Algolia keys copied from Frontend / Web bundles
- Compliance violations after credential leaks
- Attackers replaying vault-grade scopes from a laptop
How RealComposer Solves This at the Edge
Bind vault keys to the Worker
Add ALGOLIA_API_KEY to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream.
Configure upstream steps and output mapping
Use POST against https://{{secrets.ALGOLIA_APP_ID}}-dsn.algolia.net/1/indexes/{{query.index}}/query. Allowed origins on the client token should match post pipelines set cache ttl to 0 because realcomposer only stores get responses at the edge.
Call from Frontend / Web
Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.
const res = await fetch('https://realcomposer.com/v1/workspace/algolia-write-api-secure-proxy', {
headers: { Authorization: 'Bearer rc_live_your_token' }
});
{
"requestId": "req_algolia-",
"upstreamLatencyMs": 142,
"audit": {
"region": "edge",
"trace": "algolia-write-api-secure-proxy"
},
"payload": {
"id": "sample_id",
"status": "active",
"nested": {
"tags": [
"demo"
],
"internal": true
},
"unused_blob": {
"foo": "bar",
"bar": "baz"
}
}
}
{
"hitCount": "sample",
"firstHit": "sample"
}
Recipe Specs
- HTTP method
- POST
- Upstream calls
- 1
- Edge cache TTL
- No caching
- Client auth
- Restricted client token
- Mapped output fields
- 2
- Payload
- 249 B to 41 B (-84%)
curl -X POST "https://realcomposer.com/v1/workspace/algolia-write-api-secure-proxy" \
-H "Authorization: Bearer rc_live_client_token" \
-H "Content-Type: application/json" \
-d '{"model":"example"}'Developer Questions & Troubleshooting
Is it safe to log Algolia responses in Frontend / Web?
Yes for algolia-write-api-secure-proxy. Ship only an rc_live_ client token in Frontend / Web; RealComposer injects ALGOLIA_API_KEY on https://{{secrets.ALGOLIA_APP_ID}}-dsn.algolia.net/1/indexes/{{query.index}}/query.
Will Anthropic or Linear prompt bodies be rewritten?
algolia-write-api-secure-proxy POST steps bypass caches.default even if cacheTtlSeconds is set in the dashboard.
Can I restrict which domains call this pipeline?
Allowed origins on the algolia-write-api-secure-proxy client token restrict which domains may call the edge URL.
Sources & Definitions Used in This Answer
Deploy this Frontend / Web + Algolia Recipe
Clone this pre-configured pipeline into your RealComposer workspace in one click. We pre-populate upstream URLs, headers, and mapping rules.