Issue NodeJS app permissions

DavidCorral94

New Pleskian
Hey there!

I just acquired a VPS Ubuntu server. It has Plesk in order to manage it. I wanted to deploy my NodeJs application but I found an issue/question related to the permissions.

The thing is, I have this line of code:
app.use('/', express.static(path.join(__dirname + '/public')));

Which means that if I enter in http://test.com (lets say that is my domain), it should always display the content of the folder /public:
  • If I enter in http://test.com/test.js, if the test.js file does not exists (in the public folder), it should display "Cannot GET /test.js".
  • Also, If I go to http://test.com/server.js (being server.js out of the public folder, but existing) it should also display "Cannot GET /server.js" due to server.js is not in the public folder.
This is working fine in localhost and in Heroku, but not in my VPS server.

In my VPS server, if I enter in http://test.com/server.js (and server.js exists on the root of my NodeJs app folder) it displays my entire "server.js" source code, which is not good...

I think that this is a problem with permissions, but in this case I'm not an expert, so I would like to get some support from you.

Thanks and best regards!
 
Back
Top