-1

I have followed these instructions:

Enable the https-enabled Web server locally Install http-server package via npm

$ npm install -g http-server

Create the private key and certificate through openssl. The path needs to be assigned to the built fb-instant-games directory

$ cd fb-instant-games/
$ openssl genrsa 2048 > key.pem
$ openssl req -x509 -days 1000 -new -key key.pem -out cert.pem

Once the private key and certificate are ready, the Web service can be started locally via SSL.

$ http-server --ssl -c-1 -p 8080 -a 127.0.0.1

Use the browser to open https://localhost:8080 and skip the security warning displayed by the browser. This step is only to allow the browser to whitelist the above private key and certificate. If you subsequently regenerate the private key and certificate, you will need to turn on the confirmation again. It is not yet possible to preview the game directly at this step, because the preview game needs to initialize the Facebook Instant Games SDK. You need to use the following method.

Preview the game on Facebook

If you want to use all the features of the Facebook Instant Games SDK, you need to open: https://www.facebook.com/embed/instantgames/YOUR_GAME_ID/player?game_url=https://localhost:8080 in your browser. Pay attention to the YOUR_GAME_ID in the link. Replace the application number you created in Facebook.

Then you can see the game running successfully:

I followed exactly. The web server is running from the correct path. When I navigate to the URL Facebook provides for local embedding, The game doesn't initialize.

The game initializes fine if I upload the zip file to the Facebook hosting and play from my phone. It specifically doesn't work when I try to use local testing. I'm getting no errors in Chrome if I navigate to /build/fb-instant-games/ or https://localhost:8080, but if I go to https://www.facebook.com/embed/instantgames/YOUR_GAME_ID/player?game_url=https://localhost:8080 then I get this error

project.js:1 Uncaught TypeError: Cannot set property 
‘string’ of null
at CCClass.start (project.js:1)
at CCClass.eval [as _invoke] (eval at o (cocos2d-js-min.js:1), :3:65)
at CCClass.invoke (cocos2d-js-min.js:1)
at CCClass.startPhase (cocos2d-js-min.js:1)
at e.mainLoop (cocos2d-js-min.js:1)
at t (cocos2d-js-min.js:1)
halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

0

I rebuilt the cocos creator project from scratch using an empty project with the exact same script files and the problem went away. Sorry this isn't an actual fix to the problem, but it has solved the issue.