Http://localhost:1337/server/users 404 (Not Found)

Hi,
I tried self-hosting a moralis server for development. However, when I try to authenticate a user I keep getting this error http://localhost:1337/server/users 404 (Not Found).

I will appreciate some help.
Thanks

you will have to provide more info, I don’t know how to help only with this info

So the server is servered at http://localhost:1337/server. The serve is running fine
I connect with the appId and server URL like so

 <MoralisProvider appId="001" serverUrl="http://localhost:1337/server" >
      <BrowserRouter>
        <App />
      </BrowserRouter>
    </MoralisProvider>

When I try to authenticate the user using

Moralis.authenticate()

I get this 404 error.
http://localhost:1337/server/users 404 (Not Found).

you are using the authentication from this tutorial


or this one

This one
V1 Self-hosted Moralis Server

you get that error because the path was not found http://localhost:1337/server/users or because no user was created?

do you see any users in the database created in User table?

Yes, it’s true no user was created, I checked the Mongo DB database and I didn’t see any new user created.

The signup function I used was

Moralis.authenticate()

What could be the problem?

what did you use before Moralis.authenticate?

This is what i used

const { authenticate, Moralis, isAuthenticated, account, enableWeb3 } = useMoralis()
 const [ethAccount, setEthAccount] = useState('')

{isAuthenticated == false ? <Button className='button-connect' onClick={() => { Moralis.authenticate() }} variant='primary'>Connect</Button> : <Button className='button-connect' variant='primary'>{account}</Button>}

Moralis version “^1.3.1”

Does the server have to use the same version of Moralis?

you have to look in the tutorial on how to do the authentication, you have an example specific to react there

I did look at the tutorial and followed the example specific to react.
The server however returns this error

invalid data {"code":101,"stack":"Error: Moralis auth failed, invalid data\n at C:\\Users\\frawl\\Downloads\\parse-server-migration\\parse-server-migration\\src\\auth\\MoralisEthAdapter.ts:32:13\n

I don’t understand why the
enableWeb3() react function
sends invalid data to the server

Can you try cloning the two projects - Parse Server and Migration React Client, copy over your .env files and install to make sure it’s not an issue with your code.

You will need to clone the base https://github.com/MoralisWeb3/Moralis-JS-SDK to get to the demos.

Thanks, did clone them and set them up as the tutorial said but it wasn’t working. I just fixed the problem. It seems the client code on the GitHub repo is a bit misleading.

I found the answer here: Connect to your client (moralis.io)

Thanks, did clone them and set them up as the tutorial said but it wasn’t working. I just fixed the problem. It seems the client code on the GitHub repo is a bit misleading.

I found the answer here: Connect to your client (moralis.io)

That part is included in that React client repo. Or do you mean it didn’t work by default?

tbh this is really annoying and frustrating , I’m following everything on the migrating to self hosting from youtube but i get stuck on authentication , I get the same error " Http://localhost:1337/server/users 404 (Not Found)"

here’s my adopter with is the same offered by you guys from the tutorial

// Note: do not import Parse dependency. see https://github.com/parse-community/parse-server/issues/6467
/* global Parse */
import Moralis from 'moralis';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function validateAuthData(authData: any) {
  const { signature, data } = authData;

  return Moralis.Auth.verify({
    message: data,
    signature,
    networkType: 'evm',
  })
    .then((result) => {
      const authenticated = result.toJSON();
      console.log("authenitcation testing", authenticated
      )

      authData.chainId = result.result.chain.decimal;
      authData.nonce = authenticated.nonce;
      authData.address = result.result.address.checksum;
      authData.version = authenticated.version;
      authData.domain = authenticated.domain;
      authData.expirationTime = authenticated.expirationTime;
      authData.notBefore = authenticated.notBefore;
      authData.resources = authenticated.resources;
      authData.statement = authenticated.statement;
      authData.uri = authenticated.uri;
      authData.moralisProfileId = authenticated.profileId;
    })

    .catch(() => {
      // @ts-ignore (see note at top of file)
      throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Moralis auth failed, invalid data');
    });
}

function validateAppId() {
  return Promise.resolve();
}

export default {
  validateAuthData,
  validateAppId,
};

can you log the data from here, as in that message?