Adds (simple) support for Cross Origin requests to grape - this is particular useful if you want to host a Swagger UI explorer on a different domain.
Right now this module only supports a single host (or the '*' wildcard) and GET
requests only. PUT/POST support works for Safari and Chrome. The list of allowed
headers is hardcoded to be origin, content-type, accept
at the moment
Add this line to your application's Gemfile:
gem 'grape-cors'
And then execute:
$ bundle
Or install it yourself as:
$ gem install grape-cors
Add allow_cross_domain_request_from '*'
to your Grape::API sublcass:
require 'grape'
require 'grape-swagger'
require 'grape-cors'
class MyApi < Grape::API
end
class Root < Grape::API
mount MyApi
add_swagger_documentation
allow_cross_domain_request_from "*"
end
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
(c) 2012 Cambridge Healthcare Ltd. All Rights Reserved.