Sha256: a8673137faebfa462bc8869daef7fbf81d8771601926a2618676f5d72342ed55

Contents?: true

Size: 859 Bytes

Versions: 3

Compression:

Stored size: 859 Bytes

Contents

require 'rack/cors'

use Rack::Cors do
  allow do
    origins 'localhost:3000', '127.0.0.1:3000', /http:\/\/192\.168\.0\.\d{1,3}(:\d+)?/

    resource '/get-only', :methods => :get
    resource '/', :headers => :any
    resource '/single_header', :headers => 'x-domain-token'
    resource '/two_headers', :headers => %w{x-domain-token x-requested-with}
    resource '/expose_single_header', :expose => 'expose-test'
    resource '/expose_multiple_headers', :expose => %w{expose-test-1 expose-test-2}
    # resource '/file/at/*',
    #     :methods => [:get, :post, :put, :delete],
    #     :headers => :any,
    #     :max_age => 0
  end

  allow do
    origins '*'
    resource '/public'
    resource '/public_without_credentials', :credentials => false
  end
end

map '/' do
  run Proc.new { |env| [200, {'Content-Type' => 'text/html'}, ['success']] }
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rack-cors-0.2.7 test/unit/test.ru
rack-cors-0.2.6 test/unit/test.ru
rack-cors-0.2.5 test/test.ru