Previously I modify the http to https, my index was rendered quietly. But, now, with this new code to modify my server http to https, I get this error:
The localhost page isn't working. localhost didn't send any data. ERR_EMPTY_RESPONSE
server.js:
var fs = require('fs')
var app = require('./app');
var port = process.env.PORT || process.env.VCAP_APP_PORT || 3000;
var https = require('https');
var options = {
key: fs.readFileSync('certificates/xx.key'),
cert: fs.readFileSync('certificates/xx.cer')
};
https.createServer(options, app).listen(port);
app.js:
var express = require('express'); // app server
var bodyParser = require('body-parser'); // parser for post requests
var app = express();
// Bootstrap application settings
app.use(express.static('./public')); // load UI from public folder
app.use(bodyParser.json());
app.get('/', function (req, res) {
res.render("../public/index"); //the index.html route
});
//more routes... code code
app.post('/api/v1', function(req, res) {
//code.. code
});
If I add this code to test my server https, I get the same error:
https.createServer(options, app).listen(port , function(req, res) {
res.send("Hello there");
});
via Sayuri Mizuguchi
No comments:
Post a Comment