Class: FunApi::Middleware::Cors
- Inherits:
-
Object
- Object
- FunApi::Middleware::Cors
- Defined in:
- lib/funapi/middleware/cors.rb
Class Method Summary collapse
Class Method Details
.new(app, allow_origins: ["*"], allow_methods: ["*"], allow_headers: ["*"], expose_headers: [], max_age: 600, allow_credentials: false) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/funapi/middleware/cors.rb', line 4 def self.new(app, allow_origins: ["*"], allow_methods: ["*"], allow_headers: ["*"], expose_headers: [], max_age: 600, allow_credentials: false) require "rack/cors" Rack::Cors.new(app) do |config| config.allow do |allow| allow.origins(*allow_origins) allow.resource "*", methods: allow_methods, headers: allow_headers, expose: expose_headers, max_age: max_age, credentials: allow_credentials end end end |