-
Notifications
You must be signed in to change notification settings - Fork 262
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
Specify entire subdomain #30
Comments
Try this: config.middleware.use Rack::Cors do
allow do
origins '*.example.com'
resource '*', :headers => :any, :methods => [:get, :post, :options]
end
end UPDATE: This example doesn't work. Instead use the regular expression example below. |
|
@ramanbuttar is absolutely right. |
did this ever get resolved? Is there a way around it? |
Sorry - I don't know why I ever said you can do that. Wildcard doesn't work, use a regular expression instead: config.middleware.use Rack::Cors do
allow do
origins /http:\/\/(.*?)\.example\.com/
resource '*', :headers => :any, :methods => [:get, :post, :options]
end
end |
This is my regex example: /\Ahttps?:\/\/([a-zA-Z\d-]+\.){0,}example\.com\/?\z/ My example can match https and end up with top level domain. For example https://example.com.hello.world is not a valid domain. |
Does origing have to match
|
I've created a wiki for that as it might be useful for the others, later maybe it can be moved to README. Thanks @raywu for the regex and the link it was useful, I copied actually that one to the wiki |
This will match |
Is there a way to specify that an entire subdomain (let's say api.example.com) should support CORS?
In particular, I'm looking to get this working with a Grape app mounted inside of Padrino...
The text was updated successfully, but these errors were encountered: