Why a CDN is recommended
A CDN is recommended for production self-hosting when you expose Formbricks surveys publicly. It helps you:- reduce latency for survey respondents in different regions
- absorb traffic spikes on public survey links and embedded surveys
- terminate TLS and use provider features such as DDoS protection, WAF rules, and bot filtering
- serve static assets such as
/_next/*,/css/*, and/js/surveys.umd.cjscloser to end users
Recommended topology
The cleanest setup is to put the public survey domain behind the CDN and keep the admin domain separate:PUBLIC_URLhandles survey traffic, embed traffic, and public assetsWEBAPP_URLhandles the admin UI, authentication, and other private routes
What the CDN should do
Configure your CDN to proxy requests to your Formbricks origin while preserving the originalHost header and HTTPS
scheme. As a baseline, the CDN should:
- cache static assets and respect origin cache headers
- forward query strings
- bypass cache when cookies or authorization headers are present
- avoid rewriting paths or stripping prefixes
What is safe to cache
In most setups, you should only cache static public assets aggressively:/_next/*/js/*/css/*/images/*/fonts/*/icons/*/favicon.ico/storage/{environmentId}/public/*
What should bypass cache
These routes should generally not be cached:- admin routes served from
WEBAPP_URL - authentication routes such as
/api/auth/* - public client API routes such as
/api/v1/client/*and/api/v2/client/* - survey HTML routes such as
/s/*,/c/*, and/p/*unless your CDN strictly honors short origin cache headers
Important detail for upgrades
Formbricks serves the survey runtime bundle from a stable public path:Upgrade checklist
Every time you update Formbricks, include CDN cache handling in your rollout:Deploy the new Formbricks version
Update Formbricks as usual by following the Migration Guide or your normal
deployment process.
Purge or revalidate public assets
Purge the CDN cache for at least
/js/*, /_next/*, and /css/*. If your CDN
supports targeted purges, make sure /js/surveys.umd.cjs is included every time.Check the public domain after the purge
Open a survey or embedded survey through the public domain and verify in the browser network tab that the
JavaScript assets are fetched fresh from the updated release.
Practical setup guidance
Most CDN providers can be configured safely with the following approach:- Put only the public Formbricks domain behind the CDN.
- Forward all requests to your reverse proxy or load balancer.
- Cache static asset paths only.
- Bypass cache for authenticated traffic, API traffic, and survey HTML.
- Add a purge step to every Formbricks deployment or upgrade.
Troubleshooting stale content
If users still see outdated surveys or broken embeds after an upgrade, check the following:- the CDN is not overriding origin cache headers with a long fixed TTL
/js/surveys.umd.cjshas been purged or revalidated- the public domain in your SDK configuration points to
PUBLIC_URL, not the admin domain - the browser cache is cleared during verification
- your reverse proxy is forwarding the correct
HostandX-Forwarded-Protoheaders