You are not passing your express app
as an option to your https server after your credentials. So when this server is being hit with the post it doesn't know to use the express route to respond. The following code block is from This question and is the same way that I implement https and is pretty easy to read/follow.
var fs = require('fs');
var http = require('http');
var https = require('https');
var privateKey = fs.readFileSync('sslcert/server.key', 'utf8');
var certificate = fs.readFileSync('sslcert/server.crt', 'utf8');
var credentials = {key: privateKey, cert: certificate};
var express = require('express');
var app = express();
// your express configuration here
var httpServer = http.createServer(app);
var httpsServer = https.createServer(credentials, app);
httpServer.listen(80);
httpsServer.listen(443);
Notice the app
being passed as the second option in https.createServer(credentials, app);
You can do away with the httpServer if you want but doing it this way also allows you to handle http requests in whatever way that you want. This is useful if the user uses http instead of https in their address. You can then use the http server to redirect them to the secure https route.
If you continue to have CORS issues, try adding
app.all('*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.header("Access-Control-Allow-Headers", "Content-Type");
res.header("Access-Control-Allow-Methods", "DELETE, PUT, POST");
next();
});
to your express configurations. This will allow cross domain requests to your server