Selfhosted problems

Hi Fam,

Trying to selfhost Moralis Server to migrate a already running dApp.
Followed the tutorial and deployed server with heroku.
Facing the following problems:

  • XMLHttpRequest failed: “Unable to connect to the Parse API”
  • The frontend (localhost:3000) Has been blocked by CORS
  • Cloud functions are not recognized.

When running the Moralis Server locally, I can get authentication working (can add and login users and see it users are added correctly in MongoDB), But still cloud functions are not working.

I tried to configure CORS for localhost in the Server code but with no success.

Any advice?

What is the issue with cloud functions?

You don’t have to do any CORS configuration from what I know. It has to be a different issue somewhere and not related to CORS. You get a CORS error also when the server doesn’t respond.

Heres a screenshot from the console. Yes, I am also surprised, as the server code includes cors() for the server. Do not what is going on here. The cloudfunctions are “not found”

It works to access directly the server url in the browser?

What is that path with /server/login?

hm… @cryptokid when I try to access url directly in the browser I acutally get errors in the heroku log.

2023-02-26T16:00:43.669629+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/server" host=******.herokuapp.com request_id=53b14cfa-90d9-4edc-8652-673cf1a12fce fwd="62.240.134.173" dyno= connect= service= status=503 bytes= protocol=https

when i try to login a user

It looks like it crashes with a 503 error code

yea, trying to find out whats going on. at first the server/health status is ok, as soon as trying to access via frontend it crashes…

How can I see the IP of my herokuapp to allow the ip in the mongodb?

I don’t know this, maybe there are more logs and info about that IP on heroku side

tried to allow access to mongo from everywhere for now. Still want to get rid of the cors error :thinking:
How can this happen? and more importantly how can I fix this?

You still have errors now after mongo db is not blocking any IP?

Maybe is redis an issue. Aren’t there some server logs to get more info?

ok, great! It seems like i got the login working after allowing mongoDB access from everywhere (it took mongo atlas a bit to make changes effective). Will have to make this more secure later, but for now it explains alot. If we can get cloudfunctions working, that would be awesome! I get “Invalid function”
how do clound functions work with the self hosted server?

Cloud functions work the same as before. You have to add them in a file and then you have to restart the server. Try to make them work locally first.

ok, will keep trying.
now I wanted to migrate the data from the “old” mongoDB and getting a funny error. It simply adds the out_file.json items from the repo mongoDBmigration (the one from the tutorial “How to selfhost Moralis Server” description) => https://github.com/IAmJaysWay/mongoDBmigartion

This script seems to be not doing what is expected… it is somehow just inserting the hard coded stuff from the out_file.json

?

Try to dump and load the database directly with mongo dump and mongo restore

thanks will keep trying

1 Like

Try to secure the database before you load the dump