Fix OPTIONS requests

#18
This commit is contained in:
Hakan Ensari 2016-04-25 19:05:07 +01:00
parent ce44d37fe0
commit 92ed532543
2 changed files with 4 additions and 3 deletions

View File

@ -6,13 +6,13 @@ require 'quote'
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'
@ -60,7 +60,7 @@ end
# 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

View File

@ -61,5 +61,6 @@ describe 'the API' do
options '/'
refute_empty headers['Allow']
refute_empty headers['Access-Control-Allow-Headers']
last_response.must_be :ok?
end
end