HTTP Strict Transport Security (HSTS)
HTTP Strict Transport Security (HSTS) is a response header that instructs browsers to use only HTTPS for a host for a defined max-age. It protects users from downgrade and SSL stripping attacks after their first secure visit.
Technical Architecture & Deep-Dive
The Strict-Transport-Security header includes max-age and optional includeSubDomains and preload flags. Preload submission adds your domain to browser built-in lists, which is irreversible without long lead times.
Terminate TLS at your edge, redirect HTTP to HTTPS before sending HSTS, and use conservative max-age during pilots. APIs called only from your own origin inherit HSTS when the SPA and BFF share the registrable domain.
Key Architectural Benefits
Implement HTTP Strict Transport Security (HSTS) at the Edge
Deploy lightweight API aggregation, edge caching, and secret injection in minutes without Docker containers or complex servers.
Frequently Asked Questions
Q:Should JSON API subdomains send HSTS?
Yes when browsers call them directly. Pure server-to-server subdomains still benefit from enforced TLS at the load balancer.
Related Architecture Concepts
HTTP security headers are response directives that tell browsers how to handle your site: enforce HTTPS, restrict script sources, block clickjacking, and limit powerful features. They complement API auth because many attacks target how browsers mix your UI with cookies and third-party scripts.
Encryption in transit protects data while it moves across networks, typically using TLS inside HTTPS. TLS authenticates the server with certificates, negotiates session keys, and encrypts HTTP so interceptors cannot read bearer tokens, API keys, or personal data in flight.
Mutual TLS (mTLS) is an extension of TLS where both the client and the server present certificates and verify each other during the handshake. It ensures that only trusted clients with valid certificates can connect, providing strong machine-to-machine authentication.
Cross-Origin Resource Sharing (CORS) is a browser security mechanism that controls whether a web page on one origin may read responses from another origin. Servers advertise permitted caller origins and methods using HTTP response headers such as Access-Control-Allow-Origin.
Ready-to-Use Edge Recipes
Never place API_BEARER_TOKEN inside Frontend / Web source. RealComposer injects them when calling https://{{secrets.API_HOST}}/status, so browsers see only a client token.
Never place CLERK_SECRET_KEY inside Frontend / Web source. RealComposer injects them when calling https://api.clerk.com/v1/users/{{query.userId}}, so browsers see only a client token.
The Supabase service_role key bypasses all Row Level Security (RLS) rules. If leaked, an attacker has unrestricted admin access to your database. RealComposer keeps your service role key in the Secret Vault and exposes locked-down endpoints with strict output filtering.