Node.js Server shuts down in browser, but cURL request works

I am developing on an Ubuntu server that I do not have. This is my first node application.

Node.js is installed on the server. I created a simple server file:

Server.js

var http = require("http");
http.createServer(function (request, response){
    response.writeHead(200, {'Content-Type': 'text/plain'});

    //response to send out
    response.end('Hello sof');

    //print to screen
    console.log('request processed\n');
}).listen(1234);
console.log("Server Running on 1234");

In putty, I start the server with this command:

node Server.js

In another putty instance, I ran this command:

curl http://my.url.website.ca:1234/*curl request*/

In the putty instance where I ran the curl command, I get this output:

Hi sof

In the putty instance where I started the node server, this is printed on the screen:

request processed

So it looks like the server is running. However, when I put http://my.url.website.ca:1234 in my browser, I get this error:

GET http://my.url.website.ca:1234/ net :: ERR_CONNECTION_TIMED_OUT

, . - - - ? ?

+4
1

, , . , , . , .

jquery- CORS. , , , , , . , :

response.setHeader('Access-Control-Allow-Origin', 'http://acvsapps.med.uottawa.ca');
response.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');    
response.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');

!

+1

All Articles