The problem I am facing below, is only present when I upload the app into the server (Digital Ocean). When working at my local machine, I am able to make it works as the code stated below. Basicly, my jQuery Ajax request never is captured by my Node.js code. You will see that I am running the server by using express, however I have Nginx configured into the server too.
Node Set-Up:
var express = require('express');
var app = express();
var request = require("request");
var db = require('mysql');
const path = require('path');
var http = require("http").Server(app);
var io = require("/usr/local/lib/node_modules/socket.io").listen(http);
http.listen(3000, 'localhost'); //At the end of everything between here and the code.
GET Node Code:
app.use(express.static(__dirname + '/'));
app.get('/reqData',function(req,res){
//I never arrive here
console.log("print that I am here");
transform(req.query.selection1,req.query.selection2,function(){
res.json(data); //data is transformed globally
});
});
Ajax:
function requestData(){
$.ajax({
url: 'http://IPAddress/reqData',
type: 'GET',
data: {//Some stuff to send},
dataType: "json",
complete: function(data){
do(data);
},
error: function(e){
console.log(e);
}
});
}
Console Log: Chrome Console Error
EDIT 2: I have edited the ip addres on ajax, using the server's ip. (without the port). I am also attaching the new errors logs (in chrome console) and the nginx configuration.
New Console Log Chrome Log
NGINX Config: Nginx Config 1 Nginx Config 2