Przeglądaj źródła

When you run out of ideas but you still want cleaner code

Brendan Abolivier 8 lat temu
rodzic
commit
f7d1266480
Podpisane przez: Brendan Abolivier <contact@brendanabolivier.com> ID klucza GPG: 8EF1500759F70623
1 zmienionych plików z 3 dodań i 5 usunięć
  1. 3
    5
      server.js

+ 3
- 5
server.js Wyświetl plik

@@ -39,11 +39,6 @@ app.use(cors(corsOptions));
39 39
 
40 40
 app.options('*', cors(corsOptions));
41 41
 
42
-app.all('*', function(req, res, next) {
43
-    res.header('Access-Control-Allow-Headers', 'Content-Type')
44
-    next();
45
-});
46
-
47 42
 
48 43
 // A request on /register generates a token and store it, along the user's
49 44
 // address, on the tokens object
@@ -69,6 +64,9 @@ app.get('/register', function(req, res, next) {
69 64
 
70 65
 // A request on /send with user input = mail to be sent
71 66
 app.post('/send', function(req, res, next) {
67
+    // Response will be JSON
68
+    res.header('Access-Control-Allow-Headers', 'Content-Type');
69
+    
72 70
     if(!checkBody(req.body)) {
73 71
         return res.status(400).send();
74 72
     }