R
R
Roman Korolyov2019-01-28 17:17:49
Node.js
Roman Korolyov, 2019-01-28 17:17:49

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

4 answer(s)
A
Alex, 2019-01-28
@VitteDev

https://medium.com/@hydrock/%D0%BF%D0%B5%D1%80%D0%...

A
Abcdefgk, 2019-01-28
@Abcdefgk

I think it's time to start learning Node.js first.

D
DanKud, 2019-01-28
@DanKud

Write in the .htaccessfile:

<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?

M
Maxim Fedorov, 2019-01-28
@Maksclub

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 question

Ask a Question

731 491 924 answers to any question