strange fix to CORS issue - move CORS middleware to top, respond with

200 if OPTIONS request
This commit is contained in:
Tyler Renelle
2013-03-08 18:04:57 -05:00
parent 1ddd06ce38
commit 399e4b9dda
2 changed files with 8 additions and 4 deletions
+7 -3
View File
@@ -17,6 +17,10 @@ module.exports.view = (req, res, next) ->
module.exports.allowCrossDomain = (req, res, next) ->
console.log req.headers.origin
res.header "Access-Control-Allow-Origin", (req.headers.origin || "*")
res.header "Access-Control-Allow-Methods", "OPTIONS,GET,PUT,POST,DELETE"
res.header "Access-Control-Allow-Headers", "Content-Type,x-requested-with,x-api-user,x-api-key"
next()
res.header "Access-Control-Allow-Methods", "OPTIONS,GET,POST,PUT,HEAD,DELETE"
res.header "Access-Control-Allow-Headers", "Content-Type,X-Requested-With,x-api-user,x-api-key"
if req.method is 'OPTIONS'
res.send(200);
else
next()