I have a simple server on node.js running on GCE but I cannot reach the server externally. I'm not sure what is wrong as there is not much indications. Here is my code:
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var fs = require('fs');
app.use(function(req, res, next){
console.log('Request Type:', req.method);
console.log('Request query:', req.query);
next();
});
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
extended: true
}));
const PORT = 8080;
app.get("/getVideo", function (req, res){
fs.readFile('./index.html', function (err, html){
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(html);
res.end();
})
});
app.listen(PORT, '0.0.0.0');
I can ping the external ip exposed by GCE, but i just cannot reach it. Is there any other setup i need this to work? Or is the code incorrect?