From 012eb548d764eb76b1a21f40c3af97467a013d49 Mon Sep 17 00:00:00 2001 From: rautenberg Date: Tue, 2 Jun 2015 18:51:49 +0200 Subject: add switch to enable CORS support --- lib/opentox.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/opentox.rb b/lib/opentox.rb index ebd2338..be248b6 100644 --- a/lib/opentox.rb +++ b/lib/opentox.rb @@ -28,13 +28,15 @@ module OpenTox end # add CORS support for swagger - use Rack::Cors do |config| - config.allow do |allow| - allow.origins '*' - allow.resource "/#{SERVICE}/*", - :methods => [:head, :get, :post, :put, :options], - :headers => :any, - :max_age => 0 + if eval("$#{SERVICE}[:cors]") == true + use Rack::Cors do |config| + config.allow do |allow| + allow.origins '*' + allow.resource "/#{SERVICE}/", + :methods => [:head, :get, :post, :put, :delete, :options], + :headers => :any, + :max_age => 0 + end end end -- cgit v1.2.3