While trying to add the SSL to the Node js server, Everything went fine but on calling the API it shows insecure.
var fs = require('fs');
var express = require('express');
var https = require('https');
var path = require('path');
const httpsOptions = {
cert: fs.readFileSync(path.join(__dirname, 'ssl', 'certificate.crt')),
key: fs.readFileSync(path.join(__dirname, 'ssl', 'certificate.key'))
};
var app = express();
https.createServer(httpsOptions, app)
.listen(8089, function () {
console.log('Serving https://localhost:',8089);
});
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With,
Content-Type, Accept");
next();
});
app.get('/', function (req, res) {
res.send("welcome");
});
via ArUn
No comments:
Post a Comment