mirror of
https://github.com/hakanensari/frankfurter.git
synced 2024-10-29 23:32:35 +01:00
Configure rack cors
This commit is contained in:
parent
d063f1ab24
commit
2bb4aeb497
@ -13,6 +13,13 @@ configure :production do
|
||||
require 'newrelic_rpm'
|
||||
end
|
||||
|
||||
use Rack::Cors do |config|
|
||||
config.allow do
|
||||
origins '*'
|
||||
resource '*', headers: :any, methods: :get
|
||||
end
|
||||
end
|
||||
|
||||
helpers do
|
||||
def quote
|
||||
@quote ||= Quote.new(params).attributes.tap do |data|
|
||||
|
@ -53,15 +53,17 @@ describe 'the API' do
|
||||
%w(/ /latest /2012-11-20).each do |path|
|
||||
header 'Origin', '*'
|
||||
get path
|
||||
refute_empty headers['Access-Control-Allow-Methods']
|
||||
assert headers.key?('Access-Control-Allow-Methods')
|
||||
end
|
||||
end
|
||||
|
||||
it 'responds to preflight requests' do
|
||||
%w(/ /latest /2012-11-20).each do |path|
|
||||
header 'Origin', '*'
|
||||
header 'Access-Control-Request-Method', 'GET'
|
||||
header 'Access-Control-Request-Headers', 'Content-Type'
|
||||
options path
|
||||
refute_empty headers['Access-Control-Allow-Methods']
|
||||
assert headers.key?('Access-Control-Allow-Methods')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user