I have phpmyadmin, PHP , nodeJS
run on the same server and i use below code to get data from nodejs to my php website. So anyone can copy that code and add to some HTML page and chek what my nodejs server sending on this port.
Is there any way to block this nodejs server address use outside from my server??.
This is client side code
var socket = io.connect('http://xxx.xxx.xx.xx:8000');
socket.on('device', function (data) {
var commentData = JSON.parse(data);
console.log(commentData);
var cID = commentData.data.cID;
var dID = commentData.data.dID;
var status = commentData.data.status;
if(status =='online'){
$("#"+cID+dID).attr('class','online-icon');
}
if(status =='offline'){
$("#"+cID+dID).attr('class','offline-icon');
}
});
This is server side code
var express = require('express');
var socket = require('socket.io');
var http = require('http').Server(app);
var request = require('request');
var app = express();
app.use(express.static('views'));
app.set('views', 'views/product');
app.use(express.static('./public'));
var bodyParser = require('body-parser')
var server = app.listen(8000, function () {
});
var io = socket(server);
io.on('connection', function (socket) {
io.sockets.emit('device', 'test');
});