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.
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.
Public by design.
Must live in a proxy.
Mustache syntax escapes HTML. Sanitize with a library before any v-html.
A single fetch wrapper makes it easy to attach client tokens and point at a proxy.
They appear in the built JavaScript files.
Injected scripts can steal tokens from the page.
Configure allowed origins on a RealComposer pipeline and fetch it from Vue with a client token, keeping upstream keys in the vault.
No. Everything in the SPA bundle is public. Use a proxy for secret calls.
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.
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.
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.
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.
Credential leakage is the unintended exposure of secrets such as API keys, tokens, and passwords. Common sources include JavaScript bundles, decompiled mobile apps, public Git repositories, browser network logs, and low-code platform configurations visible to users.
Allowed Origins (Origin Allowlist)Allowed origins are a configured list of website domains permitted to call an API from a browser. The server or gateway checks the Origin header of each request and only returns CORS permission headers, or accepts the request, when the origin is on the allowlist.
CORS Preflight & Edge ProxyingCross-Origin Resource Sharing (CORS) is a browser security protocol that restricts web applications from making API requests to a different domain unless the server explicitly grants permission via HTTP headers. Edge proxies resolve CORS errors by terminating browser preflight OPTIONS requests directly at the edge.