Pārlūkot izejas kodu

Maybe with preflight requests?

Brendan Abolivier 8 gadus atpakaļ
vecāks
revīzija
d53cec98a6
Parakstījis: Brendan Abolivier <contact@brendanabolivier.com> GPG atslēgas ID: 8EF1500759F70623
1 mainītis faili ar 6 papildinājumiem un 3 dzēšanām
  1. 6
    3
      server.js

+ 6
- 3
server.js Parādīt failu

@@ -31,12 +31,15 @@ app.use(express.static('front'));
31 31
 app.use(bodyParser.urlencoded({ extended: true }));
32 32
 app.use(bodyParser.json());
33 33
 // Allow cross-origin requests.
34
-app.use(cors({
34
+var corsOptions = {
35 35
   origin: settings.formUrl,
36 36
   optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204
37
-}));
37
+};
38
+app.use(cors(corsOptions));
38 39
 
39
-app.all('/*', function(req, res, next) {
40
+app.options('*', cors(corsOptions));
41
+
42
+app.all('*', function(req, res, next) {
40 43
     res.header('Access-Control-Allow-Headers', 'Content-Type')
41 44
     next();
42 45
 });