Hide mailchimp api key in client side javascript
Protect Mailchimp Marketing API quota
Block browser extraction of list API keys via edge-only authorization headers. For "hide mailchimp api key in client side javascript", store MAILCHIMP_BASIC_AUTH in Secret Vault, call https://{{secrets.MAILCHIMP_DC}}.api.mailchimp.com/3.0/lists/{{query.listId}}/members?count=10 from a Worker, and let JavaScript / HTML hit only https://realcomposer.com/v1/workspace/hide-mailchimp-api-key-javascript with an rc_live_ client token.
Mailchimp keys in JavaScript / HTML network tabs
JavaScript / HTML ships code or scripts to end-user devices. Any Mailchimp bearer token in those bundles can be copied from DevTools, proxies, or repackaged apps.
- Shared JavaScript / HTML projects revealing Mailchimp tokens
- Sudden Mailchimp quota burn from scripted abuse
- Inability to rotate keys without redeploying clients
How RealComposer Solves This at the Edge
Store upstream credentials in Secret Vault
Store MAILCHIMP_BASIC_AUTH in the vault. JavaScript / HTML never embeds the raw secret, only a revocable rc_live_ client token.
Configure upstream steps and output mapping
Use GET against https://{{secrets.MAILCHIMP_DC}}.api.mailchimp.com/3.0/lists/{{query.listId}}/members?count=10. Allowed origins on the client token should match leave cache ttl at 0 when each response is user-specific (include userid or record id in query params before enabling cache).
Call from JavaScript / HTML
Allowed origins on the token should list every JavaScript / HTML host that calls this URL.
const data = await fetch('https://realcomposer.com/v1/workspace/hide-mailchimp-api-key-javascript', {
headers: { Authorization: 'Bearer rc_live_your_token' }
}).then(r => r.json());
{
"requestId": "req_hide-mai",
"upstreamLatencyMs": 142,
"audit": {
"region": "edge",
"trace": "hide-mailchimp-api-key-javascript"
},
"payload": {
"id": "sample_id",
"status": "active",
"nested": {
"tags": [
"demo"
],
"internal": true
},
"unused_blob": {
"foo": "bar",
"bar": "baz"
}
}
}
{
"memberId": "sample",
"email": "sample",
"status": "sample"
}
Recipe Specs
- HTTP method
- GET
- Upstream calls
- 1
- Edge cache TTL
- No caching
- Client auth
- Restricted client token
- Mapped output fields
- 3
- Payload
- 252 B to 56 B (-78%)
curl -X GET "https://realcomposer.com/v1/workspace/hide-mailchimp-api-key-javascript" \ -H "Authorization: Bearer rc_live_client_token"
Developer Questions & Troubleshooting
Can JavaScript / HTML call Mailchimp without holding the production key?
Log request IDs for hide-mailchimp-api-key-javascript, not raw Mailchimp payloads, because upstream bodies may include PII.
How do I forward JSON bodies to POST upstreams?
hide-mailchimp-api-key-javascript keeps cache TTL at 0 because it uses POST upstream calls or per-user responses. Add ids to query strings before enabling GET cache.
How do I rotate upstream credentials?
Allowed origins on the hide-mailchimp-api-key-javascript client token restrict which domains may call the edge URL.
Sources & Definitions Used in This Answer
Deploy this JavaScript / HTML + Mailchimp Recipe
Clone this pre-configured pipeline into your RealComposer workspace in one click. We pre-populate upstream URLs, headers, and mapping rules.