Embedding an HTML5 game on another site: https, frame headers and redirects
What a browser game needs before another site can show it in a frame: https, the right frame headers, no redirects, no mixed content. A checklist that works for any portal.
Most browser game portals, game jams and showcase pages show your game in a frame: your page, loaded inside theirs. When it works, nobody thinks about it. When it does not, you get a grey box, a browser error in the console, or a game that loads and then cannot find half its files.
The causes are nearly always the same handful. This checklist applies to any site that embeds games, not only ours.
1. Serve it over https
A secure page cannot load an insecure one inside it. If the site embedding your game uses https:// (almost every site does now), your game's address must too, with a valid certificate. Most static hosts turn https on for you; a home server or an old shared host may need setting up.
2. Allow the frame
Two response headers decide whether another site may frame your page:
X-Frame-Options: the older header.DENYblocks every frame;SAMEORIGINallows only your own site. Either one stops a portal showing your game.Content-Security-Policy: frame-ancestors: the modern way. It lists the sites that may frame you, for exampleframe-ancestors 'self' https://portal.example. When it is present, browsers ignoreX-Frame-Optionsaltogether.
If your host sends neither, any site can frame you. If it sends one that blocks, the browser console usually says so: "Refused to display … in a frame because it set 'X-Frame-Options' to 'sameorigin'". The fix is to remove that header and, if you want control, send frame-ancestors naming the sites you trust.
3. Submit the final address
Many hosts redirect: /game to /game/, or / to /index.html, or a bare domain to www. A redirect inside a frame often works, but it is one more thing to go wrong, and some sites treat it as a failure. Open your link in a browser, look at the address bar once it has settled, and submit that.
4. No mixed content
Once your page is on https, everything it loads must be too: scripts, images, sounds, fonts, and any server your game talks to. Browsers block http:// requests from a secure page, quietly, and the game simply fails to start or plays without sound. Search your build for http:// and replace each one.
5. Do not rely on navigating the top page
A framed game usually cannot change the address of the page around it, and many portals sandbox their frames. Open links in a new tab instead, and keep sign-in and saving inside your own page or the portal's SDK.
6. Mind storage
Your game keeps its own origin inside the frame, so localStorage belongs to your site. Some browsers limit storage for sites inside frames, which can make saves vanish between visits. A portal's cloud saves, where it has them, avoid that.
On Synthcade
Synthcade shows every game in a frame and checks all of this when you submit. The hosting requirements list each rule, and Hosting your game: where to start has a ready-made _headers file and the same headers for several hosts. When your page passes, publishing takes a few minutes.