From 380b915f09656f69b62f88ae5b93c983f4b32839 Mon Sep 17 00:00:00 2001 From: Kristian Garza Date: Tue, 5 Feb 2019 06:16:06 +0100 Subject: [PATCH] disable cors --- Gemfile | 1 + Gemfile.lock | 4 +++- config.ru | 10 ++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 5b919cf..cb7be56 100644 --- a/Gemfile +++ b/Gemfile @@ -17,3 +17,4 @@ gem 'middleman-dotenv', '~> 2.0' gem 'middleman-data_source', '~> 0.8.1' gem 'middleman-livereload' gem 'html-proofer', '~> 3.7', '>= 3.7.2' +gem 'rack-cors', '~> 1.0', '>= 1.0.2', :require => 'rack/cors' diff --git a/Gemfile.lock b/Gemfile.lock index 47e6ca7..404a9d4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -122,6 +122,7 @@ GEM parallel (1.11.2) public_suffix (2.0.5) rack (2.0.3) + rack-cors (1.0.2) rack-livereload (0.3.16) rack rack-test (0.6.3) @@ -156,9 +157,10 @@ DEPENDENCIES middleman-livereload middleman-sprockets (~> 4.1.0) pandoc-ruby (~> 2.0) + rack-cors (~> 1.0, >= 1.0.2) tilt (~> 2.0)! tzinfo-data wdm (~> 0.1.0) BUNDLED WITH - 1.15.2 + 1.16.4 diff --git a/config.ru b/config.ru index b1d13a5..7048805 100644 --- a/config.ru +++ b/config.ru @@ -10,4 +10,14 @@ FileUtils.mkdir('log') unless File.exist?('log') app = ::Middleman::Application.new +require 'rack/cors' +use Rack::Cors do + allow do + origins '*' + resource '*', + headers: :any, + methods: [:get, :post, :put, :patch, :delete, :options, :head] + end +end + run ::Middleman::Rack.new(app).to_app