# Call cloudinary api from vue spa without secret key

> Upload and transform URLs signed at the edge with API secret in Vault. For "call cloudinary api from vue spa without secret key", store CLOUDINARY_BASIC_AUTH in Secret Vault, call https://api.cloudinary.com/v1_1/{{secrets.CLOUDINARY_CLOUD_NAME}}/resources/image from a Worker, and let Vue / SPA hit only https://realcomposer.com/v1/workspace/call-cloudinary-from-vue-securely with an rc_live_ client token.

- Canonical page: https://realcomposer.com/recipes/call-cloudinary-from-vue-securely
- Client platform: Vue / SPA
- Upstream services: Cloudinary
- Category: Security & Secret Vault
- JSON version: https://realcomposer.com/recipes/call-cloudinary-from-vue-securely.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=call-cloudinary-from-vue-securely&via=agent

## Problem: Cloudinary keys in Vue / SPA network tabs

Vue / SPA ships code or scripts to end-user devices. Any Cloudinary bearer token in those bundles can be copied from DevTools, proxies, or repackaged apps.

- Shared Vue / SPA projects revealing Cloudinary tokens
- Sudden Cloudinary quota burn from scripted abuse
- Inability to rotate keys without redeploying clients

## Solution steps

1. **Bind vault keys to the Worker**: Create CLOUDINARY_BASIC_AUTH vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders.

2. **Set headers, mapping, and cache TTL**: Point step cloudinary at https://api.cloudinary.com/v1_1/{{secrets.CLOUDINARY_CLOUD_NAME}}/resources/image 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 Vue / SPA**: Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.

```
const { data } = await useFetch('https://realcomposer.com/v1/workspace/call-cloudinary-from-vue-securely', {
  headers: { Authorization: 'Bearer rc_live_your_token' }
});
```

## 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": "Call cloudinary api from vue spa without secret key",
  "method": "GET",
  "cacheTtlSeconds": 0,
  "authMode": "client_token",
  "steps": [
    {
      "stepKey": "cloudinary",
      "upstreamUrlTemplate": "https://api.cloudinary.com/v1_1/{{secrets.CLOUDINARY_CLOUD_NAME}}/resources/image",
      "httpMethod": "GET",
      "headersTemplate": {
        "Authorization": "Basic {{secrets.CLOUDINARY_BASIC_AUTH}}"
      },
      "timeoutMs": 3000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "publicId",
        "sourcePath": "resources.0.public_id",
        "type": "string",
        "sourceStep": "cloudinary"
      },
      {
        "targetPath": "format",
        "sourcePath": "resources.0.format",
        "type": "string",
        "sourceStep": "cloudinary"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X GET "https://realcomposer.com/v1/workspace/call-cloudinary-from-vue-securely" \
  -H "Authorization: Bearer rc_live_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_call-clo",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "call-cloudinary-from-vue-securely"
  },
  "payload": {
    "id": "sample_id",
    "status": "active",
    "nested": {
      "tags": [
        "demo"
      ],
      "internal": true
    },
    "unused_blob": {
      "foo": "bar",
      "bar": "baz"
    }
  }
}
```

Slimmed RealComposer response:

```json
{
  "publicId": "sample",
  "format": "sample"
}
```

## FAQ

### What should Vue / SPA store instead of Cloudinary secrets?

Point Vue / SPA at /recipes/call-cloudinary-from-vue-securely edge URL. RealComposer answers OPTIONS with Access-Control headers for allowed origins.

### Will Anthropic or Linear prompt bodies be rewritten?

Cache key for call-cloudinary-from-vue-securely: internal edge-cache path plus sorted query. Identical params hit; vary userId per user.

### How do I rotate upstream credentials?

Rotate vault secrets for call-cloudinary-from-vue-securely anytime; clients keep the same rc_live_ token.
