diff --git a/Gemfile b/Gemfile index 1fd6ea0..d5059cd 100644 --- a/Gemfile +++ b/Gemfile @@ -29,7 +29,7 @@ gem 'faraday' gem 'figaro' # Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible -# gem 'rack-cors' +gem 'rack-cors' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console diff --git a/Gemfile.lock b/Gemfile.lock index 6392d16..7fb2d0e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -97,6 +97,8 @@ GEM puma (3.12.6) racc (1.6.0) rack (2.2.3) + rack-cors (1.1.1) + rack (>= 2.0.0) rack-test (1.1.0) rack (>= 1.0, < 3) rails (5.2.6.2) @@ -192,6 +194,7 @@ DEPENDENCIES pg pry puma (~> 3.11) + rack-cors rails (~> 5.2.6, >= 5.2.6.2) rspec-rails rspec_junit_formatter (~> 0.2.3) diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb index 3b1c1b5..327f023 100644 --- a/config/initializers/cors.rb +++ b/config/initializers/cors.rb @@ -5,12 +5,12 @@ # Read more: https://github.com/cyu/rack-cors -# Rails.application.config.middleware.insert_before 0, Rack::Cors do -# allow do -# origins 'example.com' -# -# resource '*', -# headers: :any, -# methods: [:get, :post, :put, :patch, :delete, :options, :head] -# end -# end +Rails.application.config.middleware.insert_before 0, Rack::Cors do + allow do + origins 'http://localhost:3000' + + resource '*', + headers: :any, + methods: [:get, :post, :put, :patch, :delete, :options, :head] + end +end