[solved] React-moralis. On authentification get error 404 (Not Found)

Created a dapp server. other post requests (like ‘getTransaction’ or ‘getNativeBalance’) work, but when I try to authenticate a user I get this error:

POST https://heroku-moralis-server.herokuapp.com/server/users 404 (Not Found)

In the database, the _user table is filling, but _session is empty

The same react client works fine with the server hosted on moralis, so I think the problem is on the server side, but I don’t know how to fix it.

1 Like

did you follow this?

Paste this code:


Still getting null, but without error :
image
And session is creating

@Iulian, Combined code from documentation with code that i use, and still getting error same 404 error.

Finaly fixed, code, if anyone will stack with same error:

  import Moralis from 'moralis-v1'

  const { account, chainId, enableWeb3 } = useMoralis()

  async function userLogIn() {
    try {
      await enableWeb3({ throwOnError: true, provider: 'metamask' });

      if (!account) {
        throw new Error('Connecting to chain failed, as no connected account was found');
      }
      if (!chainId) {
        throw new Error('Connecting to chain failed, as no connected chain was found');
      }

      const { message } = await Moralis.Cloud.run('requestMessage', {
        address: account,
        chain: parseInt(chainId, 16),
        network: 'evm',
      });
      await authenticate({
        signingMessage: message,
        throwOnError: true,
      }).then((user) => {
        if (user) {
          console.log('Logged in. ', user)
        }
        else {
          console.warn('Login not working')
        }
      })
    } catch (error) {
      alert(error.message)
      console.error(error)
    }
  }
1 Like

@cryptokid mark this thread as solved, please

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.