From fc37ff5bfed6a82d35c325bc2f3b370fd5d50279 Mon Sep 17 00:00:00 2001 From: Carl Bennett Date: Fri, 16 Feb 2018 16:49:39 +1300 Subject: [PATCH] Allow cross-origin OPTIONS requests --- src/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/index.js b/src/index.js index adf7789..413f182 100755 --- a/src/index.js +++ b/src/index.js @@ -46,9 +46,13 @@ var apiReqHandler = Front.apiRequest; // disable this. See https://en.wikipedia.org/wiki/Cross-origin_resource_sharing app.use(function(req, res, next) { res.set('Access-Control-Allow-Origin', '*'); + res.set('Access-Control-Allow-Methods', 'GET,POST,PATCH,DELETE'); + res.set('Access-Control-Allow-Headers', 'Content-Type'); next(); }) +app.options('*', (req, res) => res.end()); + // Now, add the routes. // To demo some advanced functionality, we start with a route below that // constructs a customized query.