# run it with rackup ./config.ru
require 'rack/cors'
app = Rack::Builder.new do
use Rack::Cors do
allow do
origins '*'
resource '/foo', headers: :any, methods: [:post, :options]
resource '/$bar', headers: :any, methods: [:post, :options]
resource '*', headers: :any, methods: [:get, :options]
end
end
run lambda { |env|
[200, {'content-type' => 'text/html'}, ['response accepted']]
}
end
run app
Resources having a $ in the path do not work.
Example: App requirements:
With the sample app attached i get:
/foo
is returningaccess-control-allow-methods: POST, OPTIONS
as expected/baz
is returningaccess-control-allow-methods: GET, OPTIONS
as expected ( wildcard ressource)/$bar
is returningaccess-control-allow-methods: GET, OPTIONS
but it should returnaccess-control-allow-methods: POST, OPTIONS
Sample app: