diff --git a/README.md b/README.md index bfd2bcc..a24a8c5 100644 --- a/README.md +++ b/README.md @@ -230,6 +230,98 @@ The provider is SSR-safe — it only touches `window` inside `useEffect`. The lo For the App Router, mount `` in a Client Component placed inside your root layout. Server Components above it stay server-rendered. See [`examples/02-nextjs-app-router/`](./examples/02-nextjs-app-router). +## Content Security Policy + +If your site sends a `Content-Security-Policy` header, the STROMCOM origins have to be allowed. The directives below are **additive** — merge them into your existing policy. With a restrictive `default-src` (e.g. `'none'` or `'self'`) all five must be listed explicitly. + +### Production + +| Directive | Add | Why | +| ------------- | ------------------------- | ----------------------------------------------------------- | +| `script-src` | `https://cdn.stromcom.cz` | Loader script, and the widget snippet it pulls in | +| `connect-src` | `https://www.stromcom.cz` | Notification polling against `/api/app/v1/` | +| `style-src` | `https://cdn.stromcom.cz` | Widget stylesheets (shadow root + `client.css` in ``) | +| `img-src` | `data:` | SVG icons embedded in the widget CSS (loading spinner) | +| `frame-src` | `https://app.stromcom.cz` | The iframe hosting threads and the notification center | + +As a single header: + +``` +Content-Security-Policy: + script-src 'self' https://cdn.stromcom.cz; + connect-src 'self' https://www.stromcom.cz; + style-src 'self' https://cdn.stromcom.cz; + img-src 'self' data:; + frame-src https://app.stromcom.cz; +``` + +### Staging + +Same directives with the staging hosts — use these when the provider runs with `environment="staging"`. + +| Directive | Add | +| ------------- | --------------------------------- | +| `script-src` | `https://cdn.staging.stromcom.cz` | +| `connect-src` | `https://staging.stromcom.cz` | +| `style-src` | `https://cdn.staging.stromcom.cz` | +| `frame-src` | `https://app.staging.stromcom.cz` | + +`img-src data:` is the same in both environments. + +If you pass a full URL to `environment` (self-hosted or branch-preview loader, see [`examples/09-staging-environment.jsx`](./examples/09-staging-environment.jsx)), put that host in `script-src` instead. + +### `'unsafe-inline'` is not required + +`` injects the loader with `document.createElement('script')` from `useEffect` — it never emits an inline `