Call salesforce api from react without exposing access token
Secure Salesforce REST proxy for React SPAs
Vault-inject OAuth or integration tokens at the edge; React calls one public client token URL. For "call salesforce api from react without exposing access token", store SALESFORCE_ACCESS_TOKEN in Secret Vault, call https://{{secrets.SALESFORCE_INSTANCE}}.my.salesforce.com/services/data/v68.0/sobjects/Contact/{{query.contactId}} from a Worker, and let React hit only https://realcomposer.com/v1/workspace/call-salesforce-api-from-react-securely with an rc_live_ client token.
Why React leaks Salesforce credentials
Attackers routinely extract Salesforce secrets from React builds. Direct browser calls also expose internal error payloads with hostnames.
- Production Salesforce keys copied from React bundles
- Compliance violations after credential leaks
- Attackers replaying vault-grade scopes from a laptop
How RealComposer Solves This at the Edge
Store upstream credentials in Secret Vault
Store SALESFORCE_ACCESS_TOKEN in the vault. React never embeds the raw secret, only a revocable rc_live_ client token.
Configure upstream steps and output mapping
Configure headersTemplate to inject vault secrets, target https://{{secrets.SALESFORCE_INSTANCE}}.my.salesforce.com/services/data/v68.0/sobjects/Contact/{{query.contactId}}, and Add output mapping fields that mirror the JSON contract your screen already expects.
Call from React
Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.
const res = await fetch('https://realcomposer.com/v1/workspace/call-salesforce-api-from-react-securely', {
headers: { Authorization: 'Bearer rc_live_your_token' }
});
const data = await res.json();
{
"requestId": "req_call-sal",
"upstreamLatencyMs": 142,
"audit": {
"region": "edge",
"trace": "call-salesforce-api-from-react-securely"
},
"payload": {
"id": "sample_id",
"status": "active",
"nested": {
"tags": [
"demo"
],
"internal": true
},
"unused_blob": {
"foo": "bar",
"bar": "baz"
}
}
}
{
"contactId": "sample",
"email": "sample",
"name": "sample"
}
Recipe Specs
- HTTP method
- GET
- Upstream calls
- 1
- Edge cache TTL
- No caching
- Client auth
- Restricted client token
- Mapped output fields
- 3
- Payload
- 258 B to 55 B (-79%)
curl -X GET "https://realcomposer.com/v1/workspace/call-salesforce-api-from-react-securely" \ -H "Authorization: Bearer rc_live_client_token"
Developer Questions & Troubleshooting
Which Salesforce credential belongs in the vault for this pipeline?
Point React at /recipes/call-salesforce-api-from-react-securely edge URL. RealComposer answers OPTIONS with Access-Control headers for allowed origins.
Does POST traffic get cached?
Cache key for call-salesforce-api-from-react-securely: internal edge-cache path plus sorted query. Identical params hit; vary userId per user.
How do I rotate upstream credentials?
Upstream steps in call-salesforce-api-from-react-securely honor timeoutMs and optional fallback JSON without leaking secrets.
Sources & Definitions Used in This Answer
Deploy this React + Salesforce Recipe
Clone this pre-configured pipeline into your RealComposer workspace in one click. We pre-populate upstream URLs, headers, and mapping rules.