Answer the question
In order to leave comments, you need to log in
How to hide SQL data in node js?
I'm learning node js and I'm facing the same problem.
I connected the Mysql database to the app.js file, but the problem is that you can enter this file remotely by simply entering a link to it, for
example
test.ru/app.js
any user can log in and view the data.
How to hide them so that the password, login, etc. are not visible. ?
Connection example:
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: '1111111',
database: 'app',
});
Answer the question
In order to leave comments, you need to log in
Write in the .htaccess
file:
<Files "app.js">
Order Allow,Deny
Deny from all
</Files>
But the main question is - why do you need to store this file in a public folder?
It is necessary that only routes that give data via json stick out and that's it
. The code itself should be hidden below the level of the web server.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question