# Embedding YouTube videos on Azure Static Web Apps

Published: 2023-10-06
Last updated: 2023-11-21

I tried embedding a YouTube video on a page hosted on Azure Static Web Apps, but saw a "Video unavailable" error:
![](/images/2023/10/image.png)
I tried the same embed code locally and on another site, and it worked in both places. After [much](https://forem.dev/ildi/issues-with-youtube-video-embed-using-liquid-tag-40bl)[digging](https://stackoverflow.com/a/60197658), I found that this had to do with the default Referrer Policy set by Azure Static Web Apps:
![](/images/2023/10/Screenshot-2023-10-06-011359.png)
`Referrer-Policy: same-origin` would cause the browser to skip the `Referer` header for YouTube (i.e. cross-origin) requests. And it turns out, YouTube does not like that!

To fix this, override the default `Referrer-Policy` by creating a `staticwebapp.config.json` in the repository root:

```json
{
  "globalHeaders": {
    "Referrer-Policy": "strict-origin-when-cross-origin"
  }
}
```

That should update the header correctly:
![](/images/2023/10/image-3.png)
And the YouTube embed should now work like it should:
![](/images/2023/10/image-2.png)
## Links

- [Referrer policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy#directives)
- [Azure Static Web App Configuration](https://learn.microsoft.com/en-us/azure/static-web-apps/configuration#global-headers)

