[SOLVED] Trying to set up auth API for new self hosted server

So, this set off a whole slew of errors that should not exist and I dont understand.

First, I cloned the migration react client and ran it using my current server. everything ran smoothly, I signed the correct message with the appropriate data, but then I got this error


remembering an issue I had a while ago, I deleted the entry for my wallet in the __ethAddress table in my mongoDB. That had no effect.

Then, I created a fresh server and copied over my .env file.
ran yarn install
ran yarn build

error, saying the cors module was not found
it existed, so I ran npm i --save-dev @types/cors (which is what the terminal suggested.
that fixed it, I was able to run yarn build

then I tried running yarn dev to start the server
error, the module ‘ethers’ is not found
the fix for cors did not fix this
I tried manually running yarn add ethers
error, Host key verification failed.
fatal: Could not read from remote repository.

I tried copying my package.json from my current server to the new one and ran yarn install again but kept running into the same issue

For the auth is already used error you can delete the _User object for the wallet address you’re using from your MongoDB database. Can you see if that will work with your current custom Parse server?

I tried copying my package.json from my current server to the new one and ran yarn install again but kept running into the same issue

This would defeat of purpose of trying to get the second (demo) server working as it is by default.

I got your same errors with the latest parse-server-migration, but installing both @types/cors and ethers as you mentioned fixed these on my end - I did not get the host key verification failed issue. Try deleting yarn.lock and node_modules and installing everything again.

I must have gotten the code for my server while you guys were still switching it around. I had no issue installing ethers today, and I got the authentication working on the react client from both the fresh server install and from my server. There was an issue where I had to change “networkType” to “network” in the migration react client (it wouldnt let me change it on my server and I didnt want to mess with it)

However, I’m still getting errors when trying to connect my actual website.
the message request runs fine, I get the “message set” console log and I can see the api call go out and come back successfully.

the message that I sign looks like this

then the users api call fails. console shows a 404 error, network tab looks like this

console on the server logs this

error: Moralis auth failed, invalid data {"code":101,"stack":"Error: Moralis auth failed, invalid data\n    at C:\\Users\\cavan\\Documents\\code\\Moralis-Server\\src\\auth\\MoralisEthAdapter.ts:32:13\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n    at async Promise.all (index 0)"}

I think there is some error with the actual returning of the message to the front end, since the correct message does not show up to be signed. But I’m not sure where that might be, since I was able to get my server to work correctly with the migration demo front end.

In the tutorial there is a specific code for authentication that is different than the code that was working with a Moralis server. You used that code?

yes, I rewrote the authentication code to use the api auth instead of what was being used for moralis hosted servers. As it stands now, I wrote out the code from the tutorial, including the button and just replaced the old connect button with it until I get everything working.

got the code from here

That Moralis Authentication message must come from somewhere else, it wouldn’t be returned from the Auth API for you to sign. Check all your code to see where it’s coming from, there is probably something else being used.

somehow the “await” when getting the message was deleted, so undefined was being fed as the message to sign. It seems to be working now.

Thank you everyone for your help.