Self hosting Moralis Dapp + Getting 404

Hello team,

I am following this tutorial (https://www.youtube.com/watch?v=9GtysZs-FrA) to create a self hosted moralis server (using mongo and redis). I have used the parse-server-migration project and spun up the instance locally and can see it running.

Now when I switch my existing react js boiler plate app to use self hosted moralis I see 404 errors as in the snapshot

http://localhost:1337/server/users --> Getting 404 on this and my metamask authentication fails.

Hey @dileepjw,

Can you check what do you get from the network tab of calling http://localhost:1337/server/users?

Here is what am seeing

Here is the payload snapshot

Hi @dileepjw

We might need more details about the error to know what caused it.

Do you see any error logs on the code editor console? And please share the complete payload json if possible.

Thank You

This is what I see in Console:

warn: DeprecationWarning: auth.moralisEth is deprecated and will be removed in a future version. auth.moralisEth.enabled: true
error: Moralis auth failed, invalid data {“code”:101,“stack”:“Error: Moralis auth failed, invalid data\n at C:\Temp\1.Code\parse-server-migration\src\auth\MoralisEthAdapter.ts:32:13\n at processTicksAndRejections (node:internal/process/task_queues:96:5)\n at async Promise.all (index 0)”}

Please let me know if you need any settings information from my env

I had similar issues migrating an old project, it sounds like your client is using the old authentication method and the server is using the new one. When your metamask opens, does it have a whole bunch of info (Message, URI, Version, Chain ID, etc…) and a “Sign-In” button? If not your client has old auth. On server project take a look at src/auth/authService.ts, you need to call this function to get the message, then use it as the signing message in your client.

Im not sure the process of this in the client you have, I had to do it in Unity C#. Might just be a package update in your client.

My client is from old react.js boiler plate. I am trying to get self hosting done for Moralis and ended up using the parse server as a reference to test things. My MM has message and sign in button.
My client is using authenticate method from UseMoralis()

I would check your client package.json versions for react-moralis and moralis. Your authenticate message should be more than just message and sign in button. It should look like this:

The deceptive site request bit can be fixed server side, I just haven’t done it while running locally.

Thank you for the responses. Here is what I have in client
moralis: 2.7.1
react-moralis: 1.4.2

On the parse-server moralis is 2.18.2. Also here is my meta mask prompt

This is how my metamask shows on the existing working deployed application where Moralis is hosting the dapp

Hi @dileepjw

It seems like your auth props are incorrect. You need to use the requestMessage cloud function to get the message and the using it for authentication.

example

const { message } = await Moralis.Cloud.run("requestMessage", {
        address: account,
        chain: parseInt(chainId, 16),
        network: "evm",
      });

      // Authenticate and login via parse
      await authenticate({
        signingMessage: message,
        throwOnError: true,
      });

Refer to the below docs for complete code.
https://v1docs.moralis.io/moralis-dapp/getting-started/self-hosting-moralis-server/client-connection#note-about-authentication