Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Openshift: how to hide server js file in a node.js app?

The server-side javascript of my app is in a file called "server.js". If anyone runs [app-name].rhcloud.com/server.js in the browser, he will be able to read all the information inside the file. So, how do we prevent this file from being public? There are some information inside it that can't just be public, like the password of the MySQL database, etc.

like image 210
00ddie Avatar asked Aug 19 '14 22:08

00ddie


1 Answers

Commonly you might put public static files in a subdirectory like app/public which might serve up HTML, CSS, JS, or otherwise. If your application code is in server.js, you'd leave server.js in the app folder or something that is specifically not being served to the public. If you're not explicitly defining where static files are served from, then there is no issue unless you have a different web server like apache serving all app files.

like image 87
Kevin Reilly Avatar answered Oct 19 '22 23:10

Kevin Reilly