Class: Recipes::RackCors

Inherits:
Rails::AppBuilder
  • Object
show all
Defined in:
lib/potassium/recipes/rack_cors.rb

Instance Method Summary collapse

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/potassium/recipes/rack_cors.rb', line 6

def create
  gather_gem('rack-cors', '~> 0.4.0')
  after(:gem_install) do
    rack_cors_config =
      <<~RUBY
        config.middleware.insert_before 0, Rack::Cors do
          allow do
            origins '*'
            resource '*',
              headers: :any,
              expose: ['X-Page', 'X-PageTotal'],
              methods: [:get, :post, :delete, :put, :options]
          end
        end

      RUBY

    application rack_cors_config
  end
end

#installObject



2
3
4
# File 'lib/potassium/recipes/rack_cors.rb', line 2

def install
  create
end