diff --git a/Gemfile b/Gemfile index f95c1ea..045a011 100644 --- a/Gemfile +++ b/Gemfile @@ -53,3 +53,5 @@ end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] + +gem 'rack-cors' \ No newline at end of file diff --git a/config/application.rb b/config/application.rb index c238217..14b1feb 100644 --- a/config/application.rb +++ b/config/application.rb @@ -2,9 +2,17 @@ require 'rails/all' Bundler.require(*Rails.groups) + module TestRails class Application < Rails::Application config.load_defaults 5.1 + + config.middleware.insert_before 0, Rack::Cors do + allow do + origins '*' + resource '*', headers: :any, methods: [:get, :post, :options] + end + end end end diff --git a/config/routes.rb b/config/routes.rb index 92b9d67..3493121 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,7 @@ Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html - post 'checkout/cart' + post 'checkout', to: 'checkout#cart' get 'checkout/handled'