RealComposer

REST APIs Safe & Unsafe Practices

Direct Answer

For any REST API or internal microservice, credentials belong on a server or edge proxy, not in clients. Use timeouts and retries with backoff, validate any user input that ends up in upstream URLs to prevent SSRF, and return only the fields the client needs.

Credentials & Where They Belong

Server only
Bearer tokens and API keys

Any credential that authorizes calls on your behalf.

Client safe
Short-lived client tokens

Revocable tokens issued to your app instead of upstream secrets.

Safe Practices

  • Set timeouts and fallbacks per upstream

    A slow service should degrade one field, not hang the whole response.

  • Allowlist upstream hosts

    Only interpolate validated parameters into fixed hosts to prevent SSRF.

  • Project responses to a stable contract

    Mapping fields at the edge protects clients from upstream schema drift.

Unsafe Practices

  • Letting clients pass full upstream URLs

    Attackers can reach internal metadata endpoints and private services.

  • Forwarding upstream errors verbatim

    Stack traces and internal hostnames help attackers map your system.

The RealComposer Pattern

Store upstream tokens in the vault, define fixed upstream URL templates per pipeline step, and use output mapping plus timeouts with fallback JSON for resilient responses.

START BUILDING FREE

Frequently Asked Questions

Q:How do I hide a REST API key from my frontend?

Call a server or edge proxy that injects the key, and authenticate your frontend with a revocable client token.

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

Related Concepts