-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainApp.js
38 lines (36 loc) · 1.2 KB
/
MainApp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var http = require('http');
var express = require('express');
var cors = require('cors');
var app = express();
const httpsPort = 8089;
var https = require('https');
var fs = require('fs');
var options = {
key: fs.readFileSync('./key.pem', 'utf8'),
cert: fs.readFileSync('./server.crt', 'utf8')
};
//console.log("KEY: ", options.key)
//console.log("CERT: ", options.cert)
const corsOptions = {
origin: true,
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
credentials: true,
preflightContinue: true,
maxAge: 600,
};
app.options('*', cors(corsOptions));
app.use(cors(corsOptions));
//app.use(cors());
app.use(express.static('public'));
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.use(cors({ origin: 'https://localhost:8089' , credentials : true}));
var secureServer = https.createServer(options, app).listen(httpsPort, () => {
console.log(">> OAuth2 Form Demo listening at port " + httpsPort);
});
/*app.get('/oauth2', function(req, res) {
res.sendFile(__dirname + '/oauth-form.html');
});*/