Browse Source

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

Brendan Abolivier 8 years ago
parent
commit
f7d1266480
Signed by: Brendan Abolivier <contact@brendanabolivier.com> GPG key ID: 8EF1500759F70623
1 changed files with 3 additions and 5 deletions
  1. 3
    5
      server.js

+ 3
- 5
server.js View File

@@ -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
     }