|
@@ -5,6 +5,7 @@ var settings = require('./settings');
|
5
|
5
|
|
6
|
6
|
// Web server
|
7
|
7
|
var bodyParser = require('body-parser');
|
|
8
|
+var cors = require('cors');
|
8
|
9
|
var express = require('express');
|
9
|
10
|
var app = express();
|
10
|
11
|
|
|
@@ -29,11 +30,13 @@ app.use(express.static('front'));
|
29
|
30
|
// Body parsing
|
30
|
31
|
app.use(bodyParser.urlencoded({ extended: true }));
|
31
|
32
|
app.use(bodyParser.json());
|
32
|
|
-
|
33
|
|
-
|
34
|
33
|
// Allow cross-origin requests.
|
|
34
|
+app.use(cors({
|
|
35
|
+ origin: settings.formUrl,
|
|
36
|
+ optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204
|
|
37
|
+}));
|
|
38
|
+
|
35
|
39
|
app.all('/*', function(req, res, next) {
|
36
|
|
- res.header('Access-Control-Allow-Origin', settings.formUrl);
|
37
|
40
|
res.header('Access-Control-Allow-Headers', 'Content-Type')
|
38
|
41
|
next();
|
39
|
42
|
});
|