# Host page requirements

> https, Content Security Policy, permissions policy, audio files and frames: what your page must allow.

Most pages need nothing beyond the script tag. Check this page if your site sends security headers or the digital human does not appear.

## Checklist

| Requirement | Why | How to check |
|---|---|---|
| Page served over **https** (or `http://localhost` for tests) | the download cache and the shared cache need a secure context | address bar shows a lock |
| Script host allowed | the embed script is loaded from the Aimigo player host | no CSP error for `aimigo-embed.js` in the console |
| Frame host allowed | the player runs in a frame | no CSP error mentioning `frame-src` |
| Audio readable by the page | `speak({ audioUrl })` downloads the audio in your page | same origin, or the audio server sends `Access-Control-Allow-Origin` |
| Autoplay not forbidden | the frame plays audio | no `Permissions-Policy: autoplay=()` on your page |

## Content Security Policy

If your page sends a `Content-Security-Policy` header, add the Aimigo player host to three directives (keep your other sources):

```text
script-src  'self' https://player.aimigo.live;
frame-src   'self' https://player.aimigo.live;
connect-src 'self' <origin of your audio files, if not your own>;
```

- No `'unsafe-inline'` is needed: the embed script positions its frame through the DOM, not with inline styles or scripts.
- If you use `default-src` only, the browser uses it for missing directives; add the player host there or add the three directives explicitly.
- Your own `<script>` blocks that call `Aimigo.default` must be allowed by your policy as usual (put them into a file if inline scripts are forbidden).

## Permissions Policy

The frame asks for `autoplay`, `fullscreen` and `xr-spatial-tracking`. A `Permissions-Policy` header on your page that sets `autoplay=()` silences the digital human; `fullscreen=()` only disables fullscreen. Microphone input is not used by the web embed today.

## Your page inside a frame

If your page itself runs inside another site's frame, the player becomes a frame inside a frame. It works, but browsers treat the storage as third-party twice: the shared download cache is then usually not available (see [performance](https://aimigo.live/docs/performance.md)).

## Single-page apps

- Load the script tag once (in `index.html`), not inside a component that renders again on every route change.
- To show the digital human only on some routes, use `dh.hide()` / `dh.show()`. `dh.destroy()` followed by a new `Aimigo.mount()` starts the engine again.

## What the frame can and cannot do

- It cannot read your page, its cookies or its storage.
- It accepts commands only from the page origin it was created for.
- It sends messages only to that origin.
