Arquisoft / radarin_en3a

2 stars 1 forks source link

Working with deployed app #77

Closed irenebello closed 3 years ago

irenebello commented 3 years ago

While doing the deployment of the app some problems arised with the Cors. We got stuck and we don't really know how to solve this error. Whithout this we cannot see the changes in mongo or work with the database at all. How can we solve them? @pglez82

pglez82 commented 3 years ago

You need to be a little more specific with the error for me to take a look at it. What is exactly failing? Where I can see the error? Does it happen in local in heroku or both?

When we created the radarin_0 project I added some cors configuration in the restapi so it accepts petitions from everywhere:

app.options('*', cors());
app.use(cors());
irenebello commented 3 years ago

This happens in heroku, when we do a log in in the app an then we do F12 the error appears. In the restapi we have the cors configured so I don't know where the problem is.

irenebello commented 3 years ago

imagen Here appear some errors we have. In the server.js we have the lines of the cors and also the Allow from origin. But I don´t know if we need more. I think this problem may arise also with the database because a teammate change the password of the admin user so the url to connect to mongo probably is not the correct one.

irenebello commented 3 years ago

Maybe is because of this, because the error code is 503. To enter the database when the app is deployed we use the url of the mongodb with the password and the user right? Because probably the main error is that one.

pglez82 commented 3 years ago

Yes, The problem has anything to do with cors. If you log in to heroku, you can see the logs for the app radarinen3arestapi (see image attached). image That means that the restapi is unable to authenticate with mongodb atlas. If you changed the password there is the error. In the github repository you have a github secret (under settings) called MONGO_URI. This secret has the connection string (including the password) for the mongo atlas db. You need to get the new connection string (you can log in mongo atlas for getting this connection string) and update the github secret with the new url.

Another way of checking this without having to deploy to heroku would be to change the connection string locally from localhost (line 12 in file restapi/server.js) and put the mongo atlas connection string. When that works against mongo atlas, just take that url and place in the mongo_uri secret.

If you need further help let me know. Is not that easy to explain this in an issue.

irenebello commented 3 years ago

Ok, I think I know how to do this know, I will check this and I will tell you if this works. The secrect file I think I cannot access, I don´t have the settings tab of this repository. imagen

pglez82 commented 3 years ago

I changed the permissions to access the settings tab and the github secrets. You need that for make it work.

pglez82 commented 3 years ago

@UO269509 @uo269570 It is a good practice when closing the issue to inform with a comment if the problem has been solved or not and how, so the full process is well documented. Specially, if someone is helping you out with it.

UO269509 commented 3 years ago

Ok @pglez82, it was my fault, sorrry. Finanlly the issue was solved changing the password in Secrets because in one commit, doing some testing we changed the mongoUser password unintentionally.