2016-03-31 7 views
0

ローカルのhttpsサーバを設定しました。しかし、自分のサイトhttps://localhost:3001/homeや/ projectsのようなページに行くと、ページがレンダリングされません。助けてもらえますか?ここに私のコードは次のとおりです。node.js httpsサーバがアプリケーションページを表示しない

var https = require('https'); 
var fs = require('fs'); 
var https_port = 3001; 

var options = { 
    key: fs.readFileSync('./security/keys/localhost.key'), 
    cert: fs.readFileSync('./security/keys/localhost.crt') 
}; 

var a = https.createServer(options, function (req, res) { 
    res.writeHead(200); 
    console.log('https server works!); //this prints out properly 
}).listen(https_port); 
+0

res.render( 'soourceFileToBeRendered');と書かなければなりません。 か、res.end( 'hello world \ n')をチェックすることができます。 – vkstack

答えて

0

あなたは/homeまたは/projectsのようなパスをどうするか、サーバーを伝えるためにルータを使用する必要があります。

var router = require('router'); 

router.get('/home', function(req, res){ 
res.send('This is home') 
} 
+0

こんにちは - 私はすべての私のページにルーティングするルータを持っています...正常なhttpサーバを作成したが正常に動作しましたが、httpsサーバは私に問題を与えています.. –

関連する問題