Skip to content

ch1c0t/hobby-cors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

Hobby-CORS is a Rack middleware for CORS, with permissive defaults. It is available on RubyGems as hobby-cors.

By default, it responds with permissive headers to POST requests from any origin. You can use it with Hobby as follows:

require 'hobby'
require 'hobby/cors'

class App
  include Hobby
  use CORS

  post {
    'return some value'
  }
end

To restrict the origins for which CORS will be allowed, you can pass an origins Array:

require 'hobby'
require 'hobby/cors'

class App
  include Hobby

  def initialize cors_origins: nil
    if cors_headers
      use CORS, origins: cors_origins
    else
      use CORS
    end
  end

  post {
    'return some value'
  }
end

Development

To run the specs:

bundle exec rspec

About

A simple Rack middleware for CORS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages