SOuřaan Gřg
SOuřaan Gřg

Reputation: 399

how are server side script safe and hidden which are written with Node js?

First check this code which is written in node js and has used sql module on it.

var mysql      = require('mysql');
var connection = mysql.createConnection({
host     : 'localhost',
user     : 'me',
password : 'secret',
database : 'my_db'
});

connection.connect();

connection.query('SELECT 1 + 1 AS solution', function(err, rows, fields) {
 if (err) throw err;
  console.log('The solution is: ', rows[0].solution);
});

connection.end();

Above code have some private information like database name,user,password and sql query too.I am not new at node.js but not that expert on it.If a script which have been written on Node.js will save in .js format and what if it contain server side script too?I mean how can it be safe/hidden like .php do?

Upvotes: 1

Views: 867

Answers (1)

Chandan
Chandan

Reputation: 1138

Server side codes (NodeJS, PHP etc) are executed on your server and only the output of the executed code is sent to the browser or client.

Incase of NodeJS script above, it is executed on your node server. However, with the NodeJS you will need to make sure that those directories (your source code) are not served as static contents.

Upvotes: 1

Related Questions