Running a game from a local server

To make development and testing easier, you can run your game from a local server.

To do this:

  • Add the game draft using the Yandex Games Console.
  • Configure the localhost server to serve content via SSL.
  • Open the game draft by adding the ?game_url=https://localhost parameter.

Note

For security reasons, only the localhost domain is supported in the game_url parameter.

Setting up a local server

There are several ways to set up a local server. One of them is described below:

  1. Install npm following the instructions on the Node.JS website. Using npm, install the http-server package:

    > $ npm install -g http-server
    
  2. Navigate to the game directory and create a certificate and private key via openssl:

    > $ cd path/to/game/
    > $ openssl genrsa 2048 > key.pem
    > $ openssl req -x509 -days 365 -new -key key.pem -out cert.pem
    # fill in the required information
    
  3. Run the game:

    > $ http-server --ssl -c-1 -p 8080 -a 127.0.0.1
    Starting up http-server, serving ./ through https
    ...
    Available on:
    https://127.0.0.1:8080
    Hit CTRL-C to stop the server
    
  4. Open the https://localhost:8080 page in your browser. When a security warning appears, click the confirmation button.

Running the game

Open the game draft page in the browser and add a ?game_url= parameter with the game address on the local server. For example, for a game draft with the ID 96458, the link will look like this:

https://yandex.com/games/app/96458/?draft=true&game_url=https://localhost:8080

After the game launches on the local server, you can use all the SDK features from it.