Cannot use moralis services after migrating from moralis server to self-hosted parse server

Hi, I had migrated from moralis to self-hosted moralis node but it does not seem to respond to any of my queries. My current frontend is utilizing pure html css with moralis-v1 sdk. I wish to keep it that way but after hosting my server (whose parse dashboard is accessible), I am not able to query my data.

I made a simple change in my frontend as changing serverURL and appID. All logic was untouched. I started getting this error for getNFTOwners: “Failed to load resource: the server responded with a status of 403 (Forbidden)”

If I tried logging in using metamask, I got the following error:
“Uncaught (in promise) Error: Moralis auth failed, invalid data
at handleError (moralis.js:26465:17)”
and
moralis.js:26329 POST http://(app-name).us-east-1.elasticbeanstalk.com/server/users 404 (Not Found)

Just changed my config (working is commented) to my parse server config:

Hello, you have to se the app id to be the same in the server code and in the sdk in frontend

the error for invalid data could be related to auth, did you use the auth as described in documentation? (you have to do some changes for the auth to work with a self hosted server)

Hi, I have used this parse server code which I found on some forum since the main repo’s code had issues with it:

The appID is the same as the server that it is referring to. Even if the auth is changed, my frontend should be retrieving data as it is supposed to to get list of nftOwners without logging in. However, I am still facing this error and the data from blockchain is not being loaded from the parse server.

I am getting the following errors in my browser console.
image

Meanwhile, if I just change back the server’s appID and serverURL to Moralis’s hosted server config. My data is loading perfectly without even logging in.

what is the app id in your self hosted server in code?

you can check in the browser network tab to see the exact request with the parameters that it has, there should also be the app id

On my self hosted server. The appId is:
image
This is the same that I am using on my frontend.

I have been to the networks tab and clicked on the getNFTOwner request. I could not see the appID mentioned anywhere. The difference is that on my self-hosted server response, I am getting: {“error”:“unauthorized”}

Here are a few logs if I run the server on localhost:

try to use strings there instead of 001, maybe it is something else if it is not a string, as in a number

Yes, I did change appId to some other string which was not a number. It is still causing issues.

Changed the appId to “aaa” and here it is (the only request where I found appID inside the payload). The payload is of this shape:

However, the response is:
{“code”:101,“error”:“Moralis auth failed, invalid data”}

Can you please confirm if I missed any steps in setting up the backend server?

  1. I cloned the git repo.
  2. Changed config in .env file.
  3. yarn (installed dependencies)
  4. yarn build
  5. yarn dev

Just used the demo.html with the correct implementation of moralis auth. I am still getting this error:

you have to do some changes on how the authentication works, the message to sign should be a long message, not only ‘Moralis Authentication’

there is info in documentation specific to authentication, the authentication doesn’t work as it was working with a managed moralis server

I am aware of that. However, I said in my last message that I used the demo/index.html provided within this repository:

It has the auth implemented just as it should be implemented in the migration guide. I am still getting an error in that. This is what I am trying to say. All of the routes on the parse server are forbidden. Not just the auth. I have checked the appID and it is correct.

did you read about the authentication here?
https://v1docs.moralis.io/moralis-dapp/getting-started/self-hosting-moralis-server/client-connection#note-about-authentication

what is the message that you get to sign? what it is its format?

Hey. So, I reinstalled the backend and that fixed the issue. I am not sure what was going wrong there. However, other than authentication, would other methods’ implementation would also change? Like for getNFTOwners etc?

The other endpoints should work directly without changes, or at least that is my expectation

Most of the endpoints seem to be working with a few changes in arguments at a few places. However, the issue arises with using Moralis.query() function. I am not able to retrieve data from BscTransactions table from the MongoDB that is connected to my parse server. Any idea what is going wrong here? I am fairly certain that my database is connected perfectly with the parse server as new users do get inserted when performing auth. Yet I am getting a bunch of errors for this query. The error is also an empty object in response. So no idea what is going on here.

Note: I am using Moralis-v1 with nextjs.

try to see if there is more info in the server logs, it looks like a 500 error is returned somewhere

Yes, in the server logs, I am getting this error.


What may be causing this? There does exist a BscTransactions named collection

Form that error I don’t know. What is the line that generates that error? It looks like a variable is undefined