Route Velt SDK traffic through reverse proxies on your own domain. This keeps all Velt-related network calls branded to your infrastructure and satisfies strict network policies that prohibit direct connections to third-party services.Documentation Index
Fetch the complete documentation index at: https://docs.velt.dev/llms.txt
Use this file to discover all available pages before exploring further.
Why use a proxy?
- Egress control — route all Velt SDK traffic through infrastructure you own and monitor.
- Compliance — keep third-party endpoints off your app’s public egress rules.
- Custom domains — serve backend traffic from subdomains under your own brand.
- Geo-routing — place the proxy closer to your users than the nearest upstream region.
How it works
The Velt SDK talks to several backend services. You can proxy any combination of them by setting the matching field onproxyConfig:
| Service | proxyConfig field | Upstream |
|---|---|---|
| CDN — the SDK bundle itself | cdnHost | cdn.velt.dev |
| API — Velt API calls | apiHost | api.velt.dev |
| Persistence Database — Velt v2 database | v2DbHost | firestore.googleapis.com |
| Ephemeral Database — Velt realtime database | v1DbHost | *.firebaseio.com |
| Storage — file/attachment storage | storageHost | firebasestorage.googleapis.com |
| Auth — authentication token endpoints | authHost | identitytoolkit.googleapis.com + securetoken.googleapis.com |
Quick start
Point the Velt SDK at your proxy subdomains. Each field is optional — omit any host you don’t proxy and the SDK will talk to the default upstream directly.- React / Next.js
- Other Frameworks
Need to deploy the proxy server itself? See Deploy the proxy server for Cloudflare Workers and nginx walkthroughs. For per-host details (such as how the SDK rewrites RTDB hosts when
v1DbHost is set), see Configure each service.Configure each service
Reference for eachproxyConfig.* field. Use this section when you only proxy a subset of services or need the per-host implementation notes.
cdnHost
Routes the Velt SDK bundle (the JS file) through your proxy. To serve the Velt SDK via your own proxy server (e.g.,nginx) instead of Velt’s servers, provide your proxy’s base URL.
- Velt automatically appends
/lib/sdk@[VERSION_NUMBER]/velt.jsto yourproxyConfig.cdnHostto determine the full URL for fetching the SDK.- If
proxyConfig.cdnHostishttps://cdn.yourdomain.com, the SDK will be loaded fromhttps://cdn.yourdomain.com/lib/sdk@[VERSION_NUMBER]/velt.js.
- If
- Your proxy server must be configured to forward requests from
[your_proxyDomain]tohttps://cdn.velt.devwithout modifying headers or content.
- React / Next.js
- Other Frameworks
apiHost
Routes Velt API calls through your proxy. To serve the Velt APIs via your own proxy server instead of Velt’s servers, provide your proxy’s base URL usingproxyConfig.apiHost.
- Your proxy server should forward requests from your proxy host to
https://api.velt.devwithout modifying headers or content.
- React / Next.js
- Other Frameworks
v2DbHost
Routes Persistence Database (Velt v2 database) traffic through your proxy. SetproxyConfig.v2DbHost. This replaces firestore.googleapis.com for all persistence requests.
- Your proxy server should forward requests to
firestore.googleapis.comwithout modifying headers or content.
- React / Next.js
- Other Frameworks
v1DbHost
Routes Ephemeral Database (Velt v1 database) traffic through your proxy. SetproxyConfig.v1DbHost. This replaces the firebaseio.com domain in all RTDB URLs.
- Your proxy server should forward requests to
*.firebaseio.comwithout modifying headers or content.
When
v1DbHost is set, the SDK host-locks RTDB by overriding the Firebase
SDK’s internal host property setter. This prevents Firebase’s handshake from
redirecting traffic to a shard server (s-gke-*.firebaseio.com), keeping all
RTDB requests on your proxy domain for the lifetime of the connection.- React / Next.js
- Other Frameworks
storageHost
Routes File Storage (file attachments, recordings) traffic through your proxy. SetproxyConfig.storageHost. This replaces firebasestorage.googleapis.com.
- Your proxy server should forward requests to
firebasestorage.googleapis.comwithout modifying headers or content.
- React / Next.js
- Other Frameworks
authHost
Routes Auth traffic through your proxy. SetproxyConfig.authHost. This replaces both identitytoolkit.googleapis.com and securetoken.googleapis.com.
- Your proxy server should forward requests to both
identitytoolkit.googleapis.comandsecuretoken.googleapis.combased on the request path, without modifying headers or content.
The SDK caches the auth proxy host in
localStorage during initConfig(). On
subsequent page loads, the cached value is applied synchronously before Auth
can fire an internal token refresh, ensuring the refresh request goes through
your proxy rather than directly to Google.- React / Next.js
- Other Frameworks
Deploy the proxy server
Deploy a reverse proxy in front of the Velt SDK’s backend services so all Velt traffic flows through infrastructure you own. The recipes below cover the four services most customers need to proxy — Auth, v2Db, v1Db, and Storage — on Cloudflare Workers or nginx.cdnHost and apiHost are not covered by these recipes. Contact Velt support if you need to proxy the SDK CDN or the Velt API.proxyConfig (see Quick start).
Routing notes by service
| Service | Upstream | Routing notes |
|---|---|---|
| Auth | securetoken.googleapis.com + identitytoolkit.googleapis.com | Path-based: /v1/token → token-refresh upstream, else → identity upstream |
| v2Db | firestore.googleapis.com | Straight passthrough |
| v1Db | *.firebaseio.com (dynamic) | Upstream host picked per-request from the ?ns= query param. WebSocket upgrade required. |
| Storage | firebasestorage.googleapis.com | Straight passthrough |
| Platform | Best for | Setup time |
|---|---|---|
| Cloudflare Workers | Edge-distributed, zero infra | ~15 min |
| nginx | Self-hosted, full control, existing nginx infrastructure | ~45 min |
All recipes below use the open-source
velt-js/velt-proxy-server repo, which ships ready-to-deploy configs for Cloudflare Workers and nginx.Cloudflare Workers
Create four proxy subdomains
Create CNAME records for
auth-proxy, v2db-proxy, v1db-proxy, and storage-proxy under a domain you control, and attach them to your Cloudflare zone.Deploy the Workers
Each service has its own Worker in the Then bind each Worker to its subdomain via Cloudflare dashboard → Workers & Pages → Settings → Triggers → Add Custom Domain. See the Cloudflare README for the full walkthrough.
cloudflare/ folder of the velt-js/velt-proxy-server repo. Deploy all four with Wrangler:Route Auth by path
Auth splits on path:
/v1/token and /v2/token go to the token-refresh upstream, everything else goes to identity. The Worker handles this with a simple path check:Rewrite v1Db upstream from ?ns=
v1Db requests carry the Firebase namespace in the
?ns= query param. The Worker rewrites the upstream Host to the shard that owns that namespace, and special-cases the Upgrade: websocket header so RTDB streams survive:Verify
From any machine, confirm the proxies respond:You should see upstream response headers (2xx/4xx are both fine — the proxy is live).
Configure the Velt SDK
Point the Velt SDK at your proxy subdomains using the Quick start snippet. WebSockets are enabled by default, so no extra SDK configuration is required.
nginx
Thenginx/ folder of the velt-js/velt-proxy-server repo ships a Docker Compose setup with one conf.d/*.conf file per service. The snippets below summarize what each config does — see the nginx README for the full walkthrough.
Prereqs
nginx ≥ 1.18 (1.25+ for the
http2 on; directive used in the configs) built with ngx_http_proxy_module and WebSocket support, or Docker. TLS certificates covering all four subdomains (a wildcard *.yourdomain.com from Let’s Encrypt is the simplest option).Route Auth by path
Auth is path-based. Inside the
auth-proxy.yourdomain.com server block, route /v1/token to the token-refresh upstream and everything else to identity. The proxy_ssl_* directives are required so the upstream TLS handshake uses the correct SNI:Dynamic upstream for v1Db
v1Db needs the upstream host picked per-request from
?ns=. Three things are required: a resolver directive (nginx needs runtime DNS for dynamic hostnames), input validation on ?ns=, and the WebSocket upgrade headers so RTDB streams open:Passthrough for v2Db and Storage
v2Db and Storage are straight passthroughs. Use one
server block each with proxy_pass pointing at the upstream and proxy_set_header Host set to the upstream hostname. See conf.d/v2db-proxy.conf and conf.d/storage-proxy.conf for the full server blocks (including SNI, timeouts, and client_max_body_size for uploads).Configure the Velt SDK
Point the Velt SDK at your proxy subdomains using the Quick start snippet.
Advanced
Subresource Integrity (SRI)
To ensure the integrity of the Velt SDK, especially when served via a proxy, Velt leverages Subresource Integrity (SRI). SRI is a security feature that enables browsers to verify that resources they fetch (for example, from a CDN or your proxy server) are delivered without unexpected manipulation.- Default:
false
- React / Next.js
- Other Frameworks
Force long polling
Some corporate proxies and load balancers don’t support WebSocket upgrades. If your proxy is one of them, setforceLongPolling: true to force the persistence and ephemeral database connections to use long-polling instead of WebSockets.
- Default:
false
- React / Next.js
- Other Frameworks

