RealComposer
Client PlatformsOfficial Vue docs

Vue Safe & Unsafe Practices

Direct Answer

Vue single-page apps run in the browser and Vite inlines every VITE_ variable into the bundle. Keep secret keys out of Vue code, avoid v-html on untrusted content, and call private APIs through a server or edge proxy.

Credentials & Where They Belong

Client safe
VITE_ variables

Public by design.

Server only
Secret API keys

Must live in a proxy.

Safe Practices

  • Use text interpolation for API content

    Mustache syntax escapes HTML. Sanitize with a library before any v-html.

  • Centralize API calls in one client module

    A single fetch wrapper makes it easy to attach client tokens and point at a proxy.

Unsafe Practices

  • Storing secrets in VITE_ variables

    They appear in the built JavaScript files.

  • Rendering CMS HTML with v-html unsanitized

    Injected scripts can steal tokens from the page.

The RealComposer Pattern

Configure allowed origins on a RealComposer pipeline and fetch it from Vue with a client token, keeping upstream keys in the vault.

START BUILDING FREE

Frequently Asked Questions

Q:Can a Vue SPA keep an API key secret?

No. Everything in the SPA bundle is public. Use a proxy for secret calls.

Security & Secret Vault

Protect API Key in Vue SPA

Vue / SPA cannot safely store REST API production keys. Vault-bound headers reach https://jsonplaceholder.typicode.com/users/{{query.userId}} on Workers while apps call your hide-api-key-vue-spa edge URL.

Sub-10ms edgeView Recipe
Security & Secret Vault

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.

Sub-10ms edgeView Recipe
Edge Caching & Rate Limits

Cache cloudinary transformation api at edge

Cache transformation metadata responses per public_id. For "cache cloudinary transformation api at edge", 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/cache-cloudinary-transformations-edge with an rc_live_ client token. Enable 300s GET cache only when query params identify the resource.

Sub-10ms edgeView Recipe
Payload Slimmer

Cloudinary resource json trim for image picker

Return public_id format width height only from resources list. For "cloudinary resource json trim for image picker", 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/trim-cloudinary-resource-json-picker with an rc_live_ client token.

Sub-10ms edgeView Recipe

Related Concepts