This repository was archived by the owner on Dec 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
54 lines (47 loc) · 1.43 KB
/
server.js
File metadata and controls
54 lines (47 loc) · 1.43 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const express = require('express');
const app = express()
const path = require('path');
const secure = require('ssl-express-www');
const compression = require('compression');
const helmet = require('helmet');
const PORT = process.env.PORT || 4000;
if(!process.env.environment) {
require('dotenv').config();
}
// Uncommented this when ssl is setup for your app
// app.use(secure);
app.use(helmet({
contentSecurityPolicy: {
directives: {
objectSrc: [
"'none'",
],
baseUri: [
"'self'",
],
formAction: [
"'none'",
],
frameAncestors: [
"'none'",
]
}
}
}));
app.use(compression());
app.use(express.static(__dirname + '/dist/browser'));
app.use(function (req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Credentials', 'false');
res.header('Access-Control-Allow-Methods', 'GET');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
next();
});
app.get('/getEnvironment', (req, res) => {
const environment = process.env.environment;
res.status(200).json({environment});
});
app.get('*', function(req, res) {
res.sendFile(path.join(__dirname + '/dist/angular-starterpack/index.html'));
});
app.listen(PORT, () => console.log("listening on port:", PORT));