Reputation: 6358
I just changed my server to use HTTPS. I have a very boiler plate code. When I go to localhost:8888, the browser hangs and my route never gets called. Curl from the command line is the same.
I am wondering I am defining my route incorrectly. THe code is the following:
var express = require('express');
var routes = require('./routes');
var user = require('./routes/user');
var https = require('https');
var path = require('path');
var app = express();
var fs = require('fs');
// all environments
app.set('port', process.env.PORT || 8888);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.methodOverride());
app.use(app.router);
//app.use(logErrors);
app.use(express.static(path.join(__dirname, 'public')));
var options = {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')};
app.get('/', routes.index);
app.get('/users', user.list);
https.createServer(options, app.handle).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
Anyone sees what the issue is?
Upvotes: 1
Views: 170
Reputation: 146104
I think you want just app
where you have app.handle
:
https.createServer(options, app)....
Also note for cURL testing you'll need to do curl --insecure https://localhost:8888
since you are presumably using a non-commercial self-signed certificate which neither curl nor browsers will trust without a user explicit override.
Upvotes: 1
Reputation: 887887
You need to go to https://localhost:8888
.
The browser can't automatically figure out that you're listening for SSL connections on that port.
Upvotes: 1