Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only respond to OPTIONS for certain paths? #173

Open
abevoelker opened this issue Aug 13, 2018 · 0 comments
Open

Only respond to OPTIONS for certain paths? #173

abevoelker opened this issue Aug 13, 2018 · 0 comments

Comments

@abevoelker
Copy link

I'm trying to add CORS to a Rails app just for a specific path, /foo. With the following rack-cors config:

config.middleware.insert_before 0, Rack::Cors do
  allow do
    origins "example.com"
    resource "/foo", headers: :any, methods: [:get, :options]
  end
end

My application now seems to be responding with 200 OK to OPTIONS requests for arbitrary paths, such as /bar:

screenshot from 2018-08-13 15-35-58

Granted it's not responding with any valid CORS response headers, but I'm wondering if this is intended or if I'm doing something wrong. In trying to pare this down, it seems even an empty config displays this behavior:

config.middleware.insert_before 0, Rack::Cors do
end

Is there any way to strictly only respond to requests for /foo? Just getting started and trying to wrap my head around the gem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant