I have created Node js server. My ubuntu system running with two servers apache in port 443 and node js server running in port 442. Apache server running fine with SSL Certificate and but Node js is showing SSL error.
Your Connection is not private
server.js:
var express = require('express');
var https = require('https');
var http = require('http');
var fs = require('fs');
var inbox=require('./functions.js');
var app = express();
// This line is from the Node.js HTTPS documentation.
var options = {
key: fs.readFileSync('/etc/ssl/biz.key'),
cert: fs.readFileSync('/etc/ssl/biz.crt')
};
// Create a service (the app object is just a callback).
app.use(function (req, res, next) {
// Website you wish to allow to connect
res.setHeader('Access-Control-Allow-Origin', '*');
// Request methods you wish to allow
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
// Request headers you wish to allow
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
// Set to true if you need the website to include cookies in the requests sent
// to the API (e.g. in case you use sessions)
res.setHeader('Access-Control-Allow-Credentials', true);
// Pass to next layer of middleware
next();
});
// Create an HTTP service.
http.createServer(app).listen(81);
// Create an HTTPS service identical to the HTTP service.
https.createServer(options, app).listen(442,function () {
console.log('Server Time'+new Date().Now());
});
via Sarath Kumar
No comments:
Post a Comment