Game network: your server, WebSocket, CDN and large games
By default a game on InstaPlay can only reach its own games domain: the content security policy (CSP)
cuts everything else. If your game has its own server — an API, multiplayer, a WebSocket chat, a CDN
with art — list its addresses in the network field. The moderator approves the list together with the
game, players see the domains on the game page, and the browser lets the game talk to them only. Who
came to your server is proven by the player token.
The network field
In instaplay.json (CLI builds) or in the dashboard: game → “Description” → “Game network”.
{
"network": {
"connect": ["https://api.my-game.example", "wss://chat.my-game.example", "https://*.eu.my-game.example"],
"assets": ["https://cdn.my-game.example"]
},
"privacyUrl": "https://my-game.example/privacy"
}
| Group | What it is | Where it goes |
|---|---|---|
connect |
your server's API and WebSocket | connect-src — fetch, XHR, WebSocket |
assets |
a static CDN: images, sound, video, fonts, data | img-src, media-src, font-src and connect-src (engines load textures with fetch) |
script-src, worker-src, frame-src and style-src are not extended: game code, workers and
styles come from the build only (below). The exception by agreement is the script
group for large games (External code).
A non-empty network requires a privacy policy link (privacyUrl, https, up to 300 characters):
the game now sends data to your server itself, and players must know what you do with it. Without the
link the submission fails the quality bar — quality_failed with the privacyUrl field and the
privacy_required code (moderation).
Address rules
- Origin only: scheme, host and an optional port — no path,
?query,#or credentials. Case and duplicates are normalised. connect—https://orwss://;assets—https://only.- The host is a DNS name with a dot. IP addresses,
localhost,*.local,*.internalare rejected. - A wildcard is a whole leftmost label only:
https://*.eu.my-game.example. A wildcard over a public suffix (*.com,*.co.uk,*.github.io,*.cloudfront.net) is rejected — it would open other people's sites. - The portal, games domain, preview and upload hosts are not allowed — neither by name nor by a wildcard over them.
- Ad networks, trackers and third-party analytics (
google-analytics.com,mc.yandex.ru,doubleclick.netand so on) are not allowed, nor wildcards that cover them (*.yandex.ru). Game analytics goes through the SDK, ads — through the portal only. - Up to 12 addresses in total, each up to 100 characters.
The dashboard and instaplay check (check M04) show errors next to the row; the API answers
422 network_invalid with network.connect[i] fields and codes:
| Code | What is wrong |
|---|---|
scheme |
the scheme is not https:///wss:// (in assets — not https://) |
host |
a path, query or credentials in the address; a host without a dot, localhost, *.local, *.internal |
ip_literal |
an IP address instead of a name |
mask |
a wildcard not in the leftmost label, a bare * or a wildcard over a public suffix |
platform_host |
the portal, games domain, preview or upload host |
denylisted |
an ad network, tracker, third-party analytics or a wildcard over them |
too_many |
more than 12 addresses (more than 4 in script) |
too_long |
an address longer than 100 characters |
duplicate |
an assets (or script) address repeated in connect — it is in connect-src already |
script_not_allowed |
script (code from a CDN) is allowed only for studios with the external code permission, by agreement |
script_mask |
script accepts only an exact host, no wildcards |
frame_not_allowed |
frame (the game website in an iframe) is allowed only for studios with the external code permission, by agreement |
frame_mask |
frame accepts only an exact host, no wildcards |
shared_host |
the script or frame address is shared hosting (github.io, a storage.yandexcloud.net bucket, a public package CDN): use the studio's own domain or subdomain |
WebSocket
The CSP source https://api.my-game.example does not cover wss://api.my-game.example. Add a
separate wss://… row for a WebSocket — the dashboard and instaplay check remind you when a host has
https:// only. Encryption is mandatory: ws:// and http:// are rejected.
CORS on your server
The game runs on its own origin — https://<game id>.<games domain>, in preview —
https://<build id>.<preview domain>. To the browser this is a foreign site, so your server answers
with CORS headers:
Access-Control-Allow-Origin— the request origin if it is yours (match it against the games and preview domain patterns), or*for public static files;- for the
OPTIONSpreflight —Access-Control-Allow-MethodsandAccess-Control-Allow-Headers: authorization, content-type; - your site's cookies do not reach the game (browsers block third-party cookies) — send the
player token in the
Authorizationheader and issue your own session in the response.
WebSocket has no CORS — check the Origin header on connect yourself.
Player region and geo services
A game with servers in several regions needs to pick the nearest one. Options, from most to least preferred:
- Your own servers. Measure latency to your
connectaddresses or decide on your server by the request address — no new network addresses needed. - Country from the portal —
InitResult.country(SDK 1.2, init): an ISO 3166-1 alpha-2 code ('DE') ornull. Currently the portal does not pass the country to games — it is alwaysnull, so the game code must work without it. - An external geo service (country by IP) — a regular
network.connectaddress under the common rules. Explain it in the submission note (“region detection to pick the game server”) and state in the privacy policy that the player's IP address goes to that service. Advertising and tracking services are not accepted for any purpose (rules).
Network moderation
- The network is visible to players: for a published game it changes only through a submission. A submission that changes the network is reviewed for at least 48 hours: it is a security decision.
- Explain every address in the submission note: what server it is and why the game needs it. The moderator sees an added / removed diff and flags on wildcards, on addresses resolving to private networks or not resolving, and on domains that differ from the privacy policy domain.
- An extra, unexplained or third-party address is the
networkreason (reasons). - Trusted studios publish the network via the CLI without a submission, under the same rules: a build
with an invalid network is not published (
422 network_invalid). - After publication the addresses are re-checked daily: if a name starts pointing to a private network, the moderator gets a flag.
What players see
The “About the game” block on the game page shows “The game connects to the developer's servers: my-game.example” (domains from the network, without repeats) and a “Developer's privacy policy” link.
How the network is applied
- A game with a network opens at
https://<game id>.<games domain>/<build hash>-<network revision>/…: the revision is a short hash of the approved list. A new list means a new address, so players re-download the game files once.localStorageand IndexedDB are kept (the origin is the same). - Pages (
*.html) under such an address are revalidated by the browser on every start; other files are cached for a long time as before. - The previous address keeps working for a day after a network change — for open tabs. A removed address is still not guaranteed to be unreachable: old files may sit in players' browser caches.
- Unity: the
persistentDataPathfolder depends on the page address and is lost on any address change (every new build too). Keep progress in SDK saves (Unity).
No service workers
The games and preview domains answer 403 to a service worker script — registration fails. A service
worker could answer the game's requests with its own pages without CSP and bypass the address list.
Turn off engine offline and PWA modes: Godot — Progressive Web App, Construct — Offline support,
Unity — templates with an offline cache (Godot, Construct 3,
Unity).
Checks, preview and emulator
- Automated checks run the game without internet access. Requests to network addresses do not
violate R07: the report lists them separately as “from the game network”, the rest as “external”. If
the game failed to load or showed a blank frame after a request to its server, checks R06 and R19
give a
network_unreachable_in_sandboxwarning instead of a failure. A declared but unused network does not lift a failure. - Preview works with the real network: a studio link uses the current draft network (edits arrive within 30 seconds), the moderator's link uses the network from the submission (Preview).
- The emulator
instaplay devtakes the network frominstaplay.jsonand builds the same CSP as the games domain, by the moderation rules; a local server (http://localhost:…,ws://127.0.0.1:…) only with the--allow-local-networkflag and a “will not pass on the portal” warning. Protocol-relative addresses (//host) behave as on the portal under--https; without it the emulator prints CSP violations and hints when a request went tohttp://of a network host (CLI).
Large games and your CDN
Build limits do not change: zip and the unpacked build — up to 250 MB, up to 1500 files
(Uploading a build). Put heavy content on your CDN and add it to assets:
- Only data from the CDN: textures, sound, video, fonts,
.wasm,.data, asset bundles viafetch. All JS stays in the build: the Unity loader andframework.js, Phaser and Pixi bundles.script-srcis not extended, so the browser will not run a script from the CDN. - The CDN answers over HTTPS with CORS:
Access-Control-Allow-Origin: *for public static files. Load images for WebGL withcrossOrigin = "anonymous", otherwise the texture taints the canvas. - Put the version in file paths (
/v42/atlas.ktx2): addresses are immutable, and the version approved by the moderator is not silently replaced. CDN content is part of the game; moderation rules apply. - Automated checks do not download from the CDN (no internet) — the moderator checks the game in preview. An external CDN does not use the studio storage quota.
- Hundreds of megabytes of code and frequent client updates? By agreement a studio may load the code
from its CDN too — the
scriptgroup, a tiny archive and a regular probe (External code).
const img = new Image()
img.crossOrigin = 'anonymous'
img.src = 'https://cdn.my-game.example/v42/hero.webp'
await img.decode()