Developers
Content Security Policy for the UPCS Embed
Configure Content-Security-Policy so the UPCS embed script and map iframe can load: script-src, frame-src and connect-src, with a testing approach.
Updated 14 October 2026 · 2 min read
If your site sends a Content-Security-Policy header, the browser may block the UPCS embed script or its iframe until you allow them. This page lists what to check. Policies vary a lot between sites, so treat the examples as a starting point and verify them in your own browser console.
What the embed loads
- A script from
https://api.upcs.io/api/embed/upcs-embed.js. - An iframe for the map. Its address is the
embed_urlreturned when you create the session. - Requests from the embed itself happen inside the iframe, under the iframe's own policy.
Your own endpoint, such as /upcs-session, is same-origin and covered by connect-src 'self'.
Directives to adjust
Content-Security-Policy:
default-src 'self';
script-src 'self' https://api.upcs.io;
frame-src https://api.upcs.io;
connect-src 'self';
script-srcmust permithttps://api.upcs.iofor the embed script.frame-src(orchild-srcas a fallback) must permit the host ofembed_url. Inspect an actual session response to confirm the host rather than assuming.- If you load the script with a nonce-based policy, add the nonce to the script tag.
Nonces and inline code
Strict policies block inline <script> blocks, including the small snippet that calls UPCS.mount. Move the snippet into a file you serve from your own origin, or give it a per-request nonce.
<script nonce="{{ nonce }}" src="https://api.upcs.io/api/embed/upcs-embed.js"></script>
<script nonce="{{ nonce }}">/* UPCS.mount(...) */</script>
Test safely
Roll out changes with Content-Security-Policy-Report-Only first, check the console for violations, then enforce. Test with the map on desktop and mobile, and with your checkout flow.
Not the same as origins
CSP is about what your page may load. Allowed origins are about which sites may use your key's sessions. You need both to be correct. If the map fails to appear, work through handling onError and session_expired and the error codes reference.
Frequently asked questions
Which host do I need to allow?
The embed script is served from api.upcs.io, so allow that host for scripts. The map iframe URL comes from the embed_url in the session response, so confirm its host and allow it for frames.
How do I know what is blocked?
Open the browser's developer console. CSP violations are logged with the directive that blocked the request.
