Reputation: 25
I've developed a tiny app in a hosted server via cPanel, by using node js with express and mysql. so when the app is running via node or forever, it is accessible only when I add the port number in the url. but when the url is without the port, it goes to an Index of the files in the folder of the subdomain. and everyone can view the app.js file including the password to mysql and user name etc...
I thought js files are not accessible or viewable to the client??
what am i doing wrong?
Upvotes: 1
Views: 464
Reputation: 2131
Create ".htaccess" file in the root of your project with following content
RewriteEngine On
RewriteRule ^$ http://127.0.0.1:XXXX/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:XXXX/$1 [P,L]
Where the "XXXX" is the port, that you're using.
Upvotes: 1