cyu / rack-cors

Rack Middleware for handling Cross-Origin Resource Sharing (CORS), which makes cross-origin AJAX possible.
MIT License
3.26k stars 263 forks source link

Ressource with $ are not handled as expected #269

Closed aithscel closed 9 months ago

aithscel commented 9 months ago

Resources having a $ in the path do not work.

Example: App requirements:

With the sample app attached i get:

curl -H 'Origin: http://example.com' -X OPTIONS  -i 'http://127.0.0.1:9292/$bar'
HTTP/1.1 200 OK
access-control-allow-origin: *
access-control-allow-methods: GET, OPTIONS
access-control-expose-headers: 
access-control-max-age: 7200
content-type: text/html
vary: Origin
Content-Length: 17

Sample app:

# 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