When you deploy a Flows custom app, the platform applies a strict Content Security Policy (CSP) — a browser security feature that controls which external resources the app is allowed to load. CSP limits where scripts, styles, images, fonts, frames, workers, media, and network requests can come from. Most apps only need to change CSP when they call an external API, load map tiles, embed a frame, use a CDN, or add a dependency that creates workers or evaluates code at runtime. Add trusted sources inDocumentation Index
Fetch the complete documentation index at: https://docs.cognite.com/llms.txt
Use this file to discover all available pages before exploring further.
permissions.network in manifest.json.
How it works
Usemanifest.json to add trusted sources to supported fetch directives:
directives is omitted, the source is added to connect-src.
Apps can’t remove baseline restrictions, such as object-src 'none', or widen document-level directives, such as default-src and frame-ancestors. Every Flows app starts with the production baseline.
Debug CSP violations
Run the app locally:manifest.json snippet to the browser console (DevTools → Console tab):
manifest.json. The dev server picks up the change without a restart.
Production baseline
Hosted production apps use this CSP baseline:- CDF API and WebSocket endpoints are already allowed in
connect-src. - Production
script-srcallows'unsafe-inline'to be added viamanifest.json, but this is strongly discouraged. Use hash sources instead. evalandnew Function(...)are always blocked in production, regardless ofmanifest.json.style-srcincludes'unsafe-inline'because many UI libraries inject style tags.- Aura font sources are already allowed.
frame-ancestorsis controlled by App Hosting and can’t be changed frommanifest.json.
Development differences
Development uses the same baseline with a few additions for Vite and local framing:script-srcalso includes'unsafe-inline'and'unsafe-eval'for Vite HMR and React Refresh.http://localhost,http://127.0.0.1,ws://localhost, andws://127.0.0.1sources are accepted during development.- Local and preview CDF origins can frame the app.
Choose the right directive
Use the browser CSP error to identify the blocked directive, then add the narrowest source that covers it.| Requirement | Directive |
|---|---|
| External HTTPS API | connect-src |
| WebSocket | connect-src with a wss:// source |
| Map tiles, images, SVGs, or canvas textures | img-src |
| Web fonts | font-src |
| CDN stylesheet | style-src |
| Embedded iframe | frame-src |
| Audio or video | media-src |
| Worker script from another origin | worker-src |
| JavaScript file from another origin | script-src |
Manifest reference
Eachpermissions.network entry has this shape:
directives is omitted, the source is added to connect-src. The valid values for CspFetchDirective are the eight directives in Extensible directives.
Extensible directives
Only these fetch directives can be extended:default-src, frame-ancestors, object-src, base-uri, and form-action.
Source formats
Production accepts:- HTTPS sources, for example
https://api.example.testorhttps://api.example.test:8443/v1 - Secure WebSocket sources, for example
wss://stream.example.test - Host wildcards, for example
https://*.example.test
http://localhost:3000http://127.0.0.1:3000ws://localhost:5173ws://127.0.0.1:5173
script-src, production also accepts:
'wasm-unsafe-eval''strict-dynamic'- Hash sources such as
'sha256-...','sha384-...', and'sha512-...'
javascript: URLs, data: URLs, and broad wildcards, such as https://*.
Nonces are not supported — the Flows custom apps service does not generate per-request nonces.
Examples
External API
directives is omitted, the source is added to connect-src.
Map tiles
fetch() and load tile images through <img> or canvas, so they need both directives.
CDN stylesheet
WebAssembly
Common library issues
Some libraries use runtime patterns that production CSP blocks.Libraries that use eval or new Function
Templating, expression, charting, and schema libraries sometimes compile strings into functions at runtime. That requires 'unsafe-eval' in script-src, which production apps don’t allow.
Use a build-time compiler, a precompiled distribution, or a different dependency.
react-pdf and pdfjs-dist
Configure the PDF worker as a same-origin asset bundled by Vite:
'self' in worker-src.
troika-three-text and reagraph
troika-three-text, used by reagraph, probes worker support with a blob worker and can call importScripts() with generated URLs. If that path is blocked, force troika onto the main thread before any Text instances or reagraph renders are created:
Inline scripts in script-src
Adding 'unsafe-inline' to script-src allows any inline <script> tag in the app to run, which removes a meaningful layer of XSS protection. Prefer one of these alternatives:
Hash source — allowlists one specific inline script by its content hash. Nonces are not supported; hashes are the equivalent approach here.
-
Compute the SHA-256 hash of the script body (no
<script>tags, whitespace-exact): -
Add the result to
manifest.json:
.ts or .js file imported by the bundle. The bundler includes it as a same-origin script, which is covered by 'self' and requires no manifest change.
If neither option is feasible and the inline script comes from a third-party library, check whether the library offers a CSP-compatible build or configuration option before falling back to 'unsafe-inline'.
Troubleshooting
It works locally but fails in production
Check for one of these causes:- The source is
localhost,127.0.0.1,http://..., orws://.... Those are development-only. - A dependency relies on development-only
script-srcrelaxations, such as'unsafe-eval'. - The deployed bundle doesn’t include the
manifest.jsonchange. Redeploy the app after updating the manifest. - The blocked request happens inside a worker, where the dev warning may not produce a manifest snippet. Use the browser console’s CSP violation details to identify the directive and source.
The manifest rule is ignored
Check that:manifestVersionis1.sourcesisn’t empty.directivescontains at least one supported fetch directive.- The source uses an allowed scheme and doesn’t contain whitespace, semicolons, control characters, or stray quotes.
A library asks for 'unsafe-inline' in script-src
This can be added via manifest.json but is strongly discouraged — it bypasses script integrity for every inline script in the app. Use a hash source to allowlist only the specific script, or move the code to an external file. See inline scripts.
A library asks for 'unsafe-eval' in script-src
'unsafe-eval' can’t be added to production script-src. Use a CSP-safe build, precompile the dynamic code, or replace the library.
Related
- Vite plugin API —
fusionOpenPluginand development CSP. - Get started with Cognite Flows — project scaffolding, including
manifest.json. - Deploy your Flows app — how the manifest reaches App Hosting.