diff --git a/Gemfile b/Gemfile index f411bd7..f15c556 100644 --- a/Gemfile +++ b/Gemfile @@ -15,3 +15,4 @@ gem 'thin' gem 'puma' gem 'http' gem 'webrick' +gem 'rack-cors' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index ec07921..9292115 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -68,6 +68,8 @@ GEM rack (2.2.6.4) rack-accept (0.4.5) rack (>= 0.4) + rack-cors (2.0.1) + rack (>= 2.0.0) rack-protection (3.0.5) rack rake (13.0.6) @@ -114,6 +116,7 @@ DEPENDENCIES http minecraft_items puma + rack-cors rake rspec sinatra diff --git a/config.ru b/config.ru index ed47295..04d7d48 100644 --- a/config.ru +++ b/config.ru @@ -1,5 +1,13 @@ $:.unshift "app/" require 'minecraft_api' +require 'rack/cors' + +use Rack::Cors do + allow do + origins 'http://localhost:3000' + resource '*', headers: :any, methods: [:get, :post, :put, :patch, :delete, :options] + end +end run MinecraftApi \ No newline at end of file