I have an amazing problem! As I mentioned in title, Main problem is Gateway timeout but as soon as I logged in on my server the web page received data; Without stop and start my app!
Server:
I am using Ubuntu 14.04.5(GNU/Linux 4.4.0-62-generic x86_64)
Code:
I am using pm2 to run my node.js application;
The express code to run server is:
var app = http.createServer(function(req, res) {
try {
var basePath = __dirname + "/html";
var filePath = basePath + req.url;
var contentType = 'text/html';
var extname = path.extname('filePath');
switch (extname) {
case '.js':
contentType = 'text/javascript';
basePath = __dirname + '/js'
break;
case '.css':
contentType = 'text/css';
basePath = __dirname + '/css'
break;
}
if (filePath == basePath + "/") {
filePath = filePath + "login.html";
}
var page = fs.readFileSync(filePath);
res.end(page);
}
catch(err) {
console.log(error);
}
}).listen( constants.httpPort, constants.ip, function() {
console.log('Node Runs on' + process.env.OPENSHIFT_NODEJS_PORT + ' ' + process.env.OPENSHIFT_NODEJS_IP);
console.log('Listening on ' + constants.httpPort + ' ' + constants.ip);
});
I am not sure what is my problem, It is my server side and Its configuration or my code has missed a point; Really I am confused Why page load just by log in server?
via Fa.Shapouri
No comments:
Post a Comment