Class: Recipes::RackCors
- Inherits:
-
Rails::AppBuilder
- Object
- Rails::AppBuilder
- Recipes::RackCors
- Defined in:
- lib/potassium/recipes/rack_cors.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/potassium/recipes/rack_cors.rb', line 6 def create gather_gem('rack-cors', '~> 1.1') recipe = self after(:gem_install) do application recipe.rack_cors_config end end |
#install ⇒ Object
2 3 4 |
# File 'lib/potassium/recipes/rack_cors.rb', line 2 def install create end |
#rack_cors_config ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/potassium/recipes/rack_cors.rb', line 14 def rack_cors_config " config.middleware.insert_before 0, Rack::Cors do\n allow do\n origins '*'\n resource '/public/*', headers: :any, methods: :get\n resource '/api/*',\n headers: :any,\n expose: ['X-Page', 'X-PageTotal'],\n methods: [:get, :post, :patch, :put, :delete, :options]\n end\n end\n\n RUBY\nend\n" |