i have problem can't manage set node js server support ssl , can serve static files on ssl, when adding app.use(express.static(__dirname + '/public')) files being serve https regular server. 1 has tried that?
//require engines var express = require('express'); var session = require('express-session'); var bodyparser = require('body-parser') //init express engine var app = express(); //using app.use(bodyparser.json()); app.use(express.static(__dirname + '/public')); var activeport = process.env.port ? process.env.port : 4003; if (process.env.node_env === "production") { var fs = require('fs'); var https = require('https'); var options = { key: fs.readfilesync(global.approot + '/xxx.pem'), cert: fs.readfilesync(global.approot + '/yyy.crt'), passphrase: "123123", requestcert: false, rejectunauthorized: false }; var server = https.createserver(options, app).listen(activeport, function () { console.log('server listening on port ' + activeport); }); } else { app.listen(activeport, function () { console.log('server listening on port ' + activeport); }); }
try this:
const path = require('path'); // <--- require app.use(express.static(path.join(__dirname, '/dist')));
Comments
Post a Comment