Skip to content

cambridge-healthcare/grape-cors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grape-cors

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

Installation

Add this line to your application's Gemfile:

gem 'grape-cors'

And then execute:

$ bundle

Or install it yourself as:

$ gem install grape-cors

Usage

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

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Copyright

(c) 2012 Cambridge Healthcare Ltd. All Rights Reserved.

About

Cross Origin Resource Sharing support for grape

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages