0
我使用nodejs 5.9.0和express。在我的代码中,我这样创建服务器:Node.js TLS“TypeError:无法读取未定义的属性'indexOf'
var app = express();
var tls = require('tls');
var fs = require('fs');
var options = {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
};
tls.createServer(options, app).listen(3000);
var http = require('http');
http.createServer(app).listen(80);
HTTP工作正常。但是,当我试图访问https://localhost:3000,它会抛出异常如下:
C:\src\nodejs\videos\node_modules\express\lib\router\index.js:140
var search = 1 + req.url.indexOf('?');
^
TypeError: Cannot read property 'indexOf' of undefined
at Function.handle (C:\src\nodejs\videos\node_modules\express\lib\router\index.js:140:27)
at EventEmitter.handle (C:\src\nodejs\videos\node_modules\express\lib\application.js:173:10)
at Server.app (C:\src\nodejs\videos\node_modules\express\lib\express.js:38:9)
at emitOne (events.js:90:13)
at Server.emit (events.js:182:7)
at TLSSocket.<anonymous> (_tls_wrap.js:817:14)
at emitNone (events.js:80:13)
at TLSSocket.emit (events.js:179:7)
at TLSSocket._init.ssl.onclienthello.ssl.oncertcb.TLSSocket._finishInit (_tls_wrap.js:593:8)
at TLSSocket.onhandshakedone (_tls_wrap.js:65:8)
Program node bin/www exited with code 1
我有没有使用TLS的NodeJS和表达的正确方法?
谢谢!有趣的...这基本上是我最初使用的代码,但浏览器向我抛出安全异常。那么......我在最近30分钟内将我的nodejs从5.5.0升级到了5.9.0。不知道是否解决了这个问题。 –