Jump to content

Strange behavior in my Node.js application (Tommy2)


thiagoenca

Recommended Posts

Hello Heliohost managers!

I need some help, yesterday I made a upload of my Node.js application:

Name: Node.js APP

Installation path: http://marcatexto.helioho.st

My APP has these configs:

image.thumb.png.5e5256130480680ae05e25453cfdbced.png

My FTPS inside /httpdocs already has the code (I tried before create a new folder named Node following a tutorial that I found but didn't work too):

image.thumb.png.bdfdaf96e3d29fffd11f85e8e7624448.png

I already ran the npm install (button) and restart app (button).

But what is happening is so weird, because when I try to test my route (http://marcatexto.helioho.st/login) it's showing a error handling message that I created when someone try to access other routes without a token that I created as below. The thing is, this route doesn't need this token to work, because this route generate the token that I will use in other routes:

image.thumb.png.53f22fe3ebf53321278b015504aef59c.png

You could think that is an issue with my app, right? But when I try to run locally, with HelioHost database is working perfectly:

image.thumb.png.5dc20804106604e9677cab0ed9dd13ea.png

So, I'm pretty lost about how to proceed. The screenshot below shows my app.js file:

image.thumb.png.09a27267f8fed349afc79c67e9331129.png

Can someone give me some help, please?

Link to comment
Share on other sites

31 minutes ago, Unknown025 said:

It's a bit hard to tell what your issue is without seeing what your routing for the authentication looks like, but you could check the logs for any errors regarding connecting to the database or rejecting requests with a 401.

Hey, I looked the logs but it's not bringing so clear information:
 

image.thumb.png.f798c9639c037317a9ef2c75cd07c722.png

image.thumb.png.af7c48f5dd40944fc4493eee6fea4330.png

Would help if you have access to the code?


But for me doesn't make sense work in local and not in heliohost server (it seems that it is lost)

image.png

Link to comment
Share on other sites

I noticed some differences from this tutorial (https://wiki.helionet.org/tutorials/node.js😞

1. The cpanel is different now, and we can't register an application. Now our app is already there. So I couldn't change the path to node as mentioned in the tutorial nether application url.

Now, what we have is this:

image.png.8022a293dcc3e9bc114f1bc2c53ab750.png

If I try to change document root to "node" folder it doesn't allow me to do this. 

Link to comment
Share on other sites

6 minutes ago, thiagoenca said:

So I couldn't change the path to node as mentioned in the tutorial nether application url.

On Plesk you can't run node apps in a subdirectory. They have to be at the webroot.  

4 hours ago, thiagoenca said:

But when I try to run locally, with HelioHost database is working perfectly:

Are you using Passenger locally too?

Link to comment
Share on other sites

10 minutes ago, Krydos said:

On Plesk you can't run node apps in a subdirectory. They have to be at the webroot.  

Are you using Passenger locally too?

@KrydosThe structure that I've now is this: image.png

My code is inside "node" folder and "httpdocs". Both are sending me the same message mentioned above.

Sorry, I don't know what is Passenger. But to make work in my codebase locally, I just placed the database info into my .env file:

image.png.7194a390488e7ba002591177748e3953.png

 

What changes I should do to make work? 

 

Link to comment
Share on other sites

I would simplify things a bit. Your pages are returning error code 401 which means authorization required. They should be returning 200 ok. Maybe try setting up a test app that doesn't have database connection, and all the other complications. Then if that works you can build from that and make small changes. If you get an error after a change you can know what the issue is. The way things are now it could be 500 different things causing the issue, and it's difficult to narrow it down.

The other thing that might be useful is installing Passenger locally so you have a more similar development environment in case that is what is causing issues.

Link to comment
Share on other sites

3 minutes ago, Krydos said:

I would simplify things a bit. Your pages are returning error code 401 which means authorization required. They should be returning 200 ok. Maybe try setting up a test app that doesn't have database connection, and all the other complications. Then if that works you can build from that and make small changes. If you get an error after a change you can know what the issue is.

I don't think this would be the best approach for me now, since I have a lot of code and locally it's working with heliohost db. It's seems some configuration error.

 

When you say that the code should be in webroot, you mean that should below to `Home directory` but at same level that .npm, .git, ... this?

Link to comment
Share on other sites

1 hour ago, thiagoenca said:

When you say that the code should be in webroot, you mean that should below to `Home directory` but at same level that .npm, .git, ... this?

Webroot means marcatexto.helioho.st. Subdirectory would be something like marcatexto.helioho.st/node. You can also use the webroot of a subdomain like node.marcatexto.helioho.st.

1 hour ago, thiagoenca said:

I don't think this would be the best approach for me now, since I have a lot of code and locally it's working with heliohost db. It's seems some configuration error.

Up to you. I've been developing software for quite a few years and it's always easier to start simple and debug one problem at a time than start at maximum complexity and debug 100 issues at the same time.  

1 hour ago, thiagoenca said:

I have a lot of code and locally it's working

This doesn't really mean anything if your development environment is different than your production environment. It's like saying my boat works fine when it's on my development lake, but it doesn't work at all on my production parking lot. The environment of a lake and a parking lot are quite different.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...