Skip to content

Commit

Permalink
Handle pre-flight requests for CORS. Closes #32
Browse files Browse the repository at this point in the history
  • Loading branch information
Raathigesh committed Aug 17, 2016
1 parent a923144 commit f3d4408
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/server/endpoints/http.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
function httpModule(app, spec) {

/**
* To support CORS pre-flight requests.
*/
app.options("/*", function(req, res, next){
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
res.send(200);
});

for (var i = 0; i < spec.endpoints.length; i++) {
addRoute(app, spec.endpoints[i]);
}
Expand Down

0 comments on commit f3d4408

Please sign in to comment.