forked from aws-samples/amazon-cognito-vue-workshop
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.js
31 lines (27 loc) · 859 Bytes
/
server.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
// init project
//const AmazonCognitoIdentity = require('amazon-cognito-identity-js');
//require('dotenv');
const express = require('express');
//const cookieParser = require('cookie-parser');
//const hbs = require('hbs');
const authn = require('./src/libs/authn');
//const helmet = require('helmet');
const app = express();
//app.use(helmet());
//app.use(cookieParser());
app.use(express.json());
app.use(express.static('public'));
app.use((req, res, next) => {
if (req.get('x-forwarded-proto') &&
(req.get('x-forwarded-proto')).split(',')[0] !== 'https') {
return res.redirect(301, `https://${req.get('host')}`);
}
req.schema = 'https';
next();
});
app.use('/authn', authn);
// listen for req :)
const port = 8081;
const listener = app.listen(port, () => {
console.log('Your app is listening on port ' + listener.address().port);
});