# Contentful headless cms edge proxy for webflow

> Single edge endpoint for Webflow fetch with CORS and auth. For "contentful headless cms edge proxy for webflow", store CONTENTFUL_ACCESS_TOKEN in Secret Vault, call https://cdn.contentful.com/spaces/{{query.spaceId}}/entries from a Worker, and let Webflow hit only https://realcomposer.com/v1/workspace/contentful-edge-proxy-for-webflow with an rc_live_ client token.

- Canonical page: https://realcomposer.com/recipes/contentful-edge-proxy-for-webflow
- Client platform: Webflow
- Upstream services: Contentful
- Category: Platforms & Frameworks
- JSON version: https://realcomposer.com/recipes/contentful-edge-proxy-for-webflow.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=contentful-edge-proxy-for-webflow&via=agent

## Problem: Webflow cannot attach secret headers to Contentful

Webflow runs in the browser or a sandbox without a secret store. Contentful rejects unsigned browser origins or requires server-only headers.

- Proxy hacks that break when vendors tighten CSP
- Zapier-only workarounds adding cost and latency
- Guest users seeing failed network requests in demos

## Solution steps

1. **Add vault secrets for this pipeline**: Add CONTENTFUL_ACCESS_TOKEN to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream.

2. **Configure upstream steps and output mapping**: Point step contentful at https://cdn.contentful.com/spaces/{{query.spaceId}}/entries with GET. Add output mapping fields that mirror the JSON contract your screen already expects. Leave cache TTL at 0 when each response is user-specific (include userId or record id in query params before enabling cache).

3. **Call from Webflow custom code**: Allowed origins on the token should list every Webflow host that calls this URL.

```
fetch('https://realcomposer.com/v1/workspace/contentful-edge-proxy-for-webflow', {
  headers: { Authorization: 'Bearer rc_live_your_token' }
}).then(r => r.json());
```

## Pipeline config

Import this config into a RealComposer pipeline. `{{secrets.NAME}}` values are read from the encrypted Secret Vault at request time, so the client never sees them.

```json
{
  "name": "Contentful headless cms edge proxy for webflow",
  "method": "GET",
  "cacheTtlSeconds": 0,
  "authMode": "client_token",
  "steps": [
    {
      "stepKey": "contentful",
      "upstreamUrlTemplate": "https://cdn.contentful.com/spaces/{{query.spaceId}}/entries",
      "httpMethod": "GET",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.CONTENTFUL_ACCESS_TOKEN}}"
      },
      "timeoutMs": 3000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "entryId",
        "sourcePath": "items.0.sys.id",
        "type": "string",
        "sourceStep": "contentful"
      },
      {
        "targetPath": "title",
        "sourcePath": "items.0.fields.title",
        "type": "string",
        "sourceStep": "contentful"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X GET "https://realcomposer.com/v1/workspace/contentful-edge-proxy-for-webflow" \
  -H "Authorization: Bearer rc_live_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_contentf",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "contentful-edge-proxy-for-webflow"
  },
  "payload": {
    "id": "sample_id",
    "status": "active",
    "nested": {
      "tags": [
        "demo"
      ],
      "internal": true
    },
    "unused_blob": {
      "foo": "bar",
      "bar": "baz"
    }
  }
}
```

Slimmed RealComposer response:

```json
{
  "entryId": "sample",
  "title": "sample"
}
```

## FAQ

### Can Webflow call Contentful without holding the production key?

Store CONTENTFUL_ACCESS_TOKEN for contentful-edge-proxy-for-webflow. Webflow never sees decrypted values.

### Does POST traffic get cached?

contentful-edge-proxy-for-webflow forwards client JSON to POST upstreams unchanged; secrets interpolate only in URLs and header templates.

### What happens if an upstream step times out?

Upstream steps in contentful-edge-proxy-for-webflow honor timeoutMs and optional fallback JSON without leaking secrets.
