Navigation Menu

Skip to content

Commit

Permalink
Fix OPTIONS requests
Browse files Browse the repository at this point in the history
  • Loading branch information
hakanensari committed Apr 25, 2016
1 parent ce44d37 commit 92ed532
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/api.rb
Expand Up @@ -6,13 +6,13 @@

configure do
set :options_response_headers,
'Allow' => 'HEAD, GET, OPTIONS',
'Allow' => 'GET, HEAD, OPTIONS',
'Access-Control-Allow-Headers' => 'X-Requested-With, X-HTTP-Method-Override, Content-Type, Cache-Control, Accept'

set :cors_response_headers,
'Access-Control-Allow-Credentials' => 'true',
'Access-Control-Allow-Headers' => '*, Content-Type, Accept, AUTHORIZATION, Cache-Control',
'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS',
'Access-Control-Allow-Methods' => 'GET, HEAD, OPTIONS',
'Access-Control-Allow-Origin' => '*',
'Access-Control-Expose-Headers' => 'Cache-Control, Content-Language, Content-Type, Expires, Last-Modified, Pragma',
'Access-Control-Max-Age' => '1728000'
Expand Down Expand Up @@ -60,7 +60,7 @@ def enable_cross_origin
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Preflighted_requests
options '*' do
headers settings.options_response_headers
pass
200
end

get '/' do
Expand Down
1 change: 1 addition & 0 deletions spec/api_spec.rb
Expand Up @@ -61,5 +61,6 @@
options '/'
refute_empty headers['Allow']
refute_empty headers['Access-Control-Allow-Headers']
last_response.must_be :ok?
end
end

0 comments on commit 92ed532

Please sign in to comment.