[SOLVED] How to Using Unity SDK with self-hosted server?

Hello! I can’t setup Unity with Self-hosted Moralis server. I found only one article about this solution. But it’s work not as expected.

Do somebody have some guides, information or etc about that?

Ps. For Windows builds everything work well by article above. But for WebGL not.

But for WebGL not.

Did you make the same changes to the AuthenticationKit.cs file - covered in these instructions in the post?

For WebGL, follow the same steps in the code above in the same AuthenticationKit.cs file (near the top) and use Web3GL.ChainId() instead of session.ChainId .

Which Unity editor version and Moralis game kit version are you using?

  • Moralis Game Kit version: 1.2.11
  • Unity editor version: 2021.3.2f1

Yes, I did this step. And try another solutions. Problem start with messege signature in Metamask - its like Null (pic). I had same problem with self-hosted server with another platforms, before found your article.

“GET https://****.dev/15834064 404 (Not Found)” - I Get after click “connect”
After signature in Metamask (pic) I get /users/ (404 not found)

meta

Based on the MetaMask message (Moralis Authentication.. which is the default message for authenticating with hosted servers), it looks like you have missed some steps - with a self-hosted server, it needs to use the Auth API. The MetaMask message to sign should look something like:

I would suggest starting over with the steps and make sure it works locally first before deploying your self-hosted server.

1 Like

Now I Fix It!

I Add

IDictionary<string, object> requestMessageParams = new Dictionary<string, object>();

requestMessageParams.Add("address", address);
requestMessageParams.Add("chain", Web3GL.ChainId());
requestMessageParams.Add("network", "evm");

Dictionary<string, object> authMessage = await Moralis.Cloud.RunAsync<Dictionary<string, object>>("requestMessage", requestMessageParams);

signMessage = authMessage["message"].ToString();

Above line 267 // Try to sign and catch the Exception when a user cancels the request too

Perhaps you @alex mean meant it, but I was not attentive. At First I add this only in one place - here