My node applications runs fine with http but in https it throws cors error and my ssl port link (<https://www.example.com:3001>) works fine and loads.. So ssl settings are fine but the cors issue is not allowing to submit the form.. 

The following is the code for http which is working fine.. Can anyone check and fix the issue..

```js
var express = require('express');

var DataController = require('./user/DataController');
var UserController = require('./user/UserController');
var db = require('./database/dbbase-db'); 
var cors = require('cors');
var app = express();
app.use(cors());

app.use(function(req, res, next) {
res.setHeader("Access-Control-Allow-Origin", "https://www.example.com");
res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.setHeader('Access-Control-Allow-Methods', 'POST');
res.setHeader('Access-Control-Allow-Credentials', true);
next();
});

app.use('/user', UserController);
app.use('/data', DataController);
app.get('/', function(req, res){
res.send("Welcome");
});

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

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

https.createServer(options, function (req, res) {
  res.writeHead(200);
  res.end("Welcome");
}).listen(3001);

// app.listen(3001, function () {
// console.log('Welcome')
// })
```