Set Access-Control-Max-Age header for CORS preflight requests to cache them (refs travis-pro/post-its#169)
This commit is contained in:
parent
1615928c68
commit
2a66505aca
|
@ -15,6 +15,11 @@ class Travis::Api::App
|
||||||
options // do
|
options // do
|
||||||
headers['Access-Control-Allow-Methods'] = "HEAD, GET, POST, PATCH, PUT, DELETE"
|
headers['Access-Control-Allow-Methods'] = "HEAD, GET, POST, PATCH, PUT, DELETE"
|
||||||
headers['Access-Control-Allow-Headers'] = "Content-Type, Authorization, Accept, If-None-Match, If-Modified-Since, X-User-Agent, Travis-API-Version"
|
headers['Access-Control-Allow-Headers'] = "Content-Type, Authorization, Accept, If-None-Match, If-Modified-Since, X-User-Agent, Travis-API-Version"
|
||||||
|
|
||||||
|
# cache OPTIONS for 24 hours to avoid excessive preflight requests and speed up access
|
||||||
|
# browsers might still limit this value to 10 minutes, see caveats
|
||||||
|
# http://stackoverflow.com/a/12021982
|
||||||
|
headers['Access-Control-Max-Age'] = "86400"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,5 +46,9 @@ describe Travis::Api::App::Cors do
|
||||||
it 'sets Access-Control-Allow-Headers' do
|
it 'sets Access-Control-Allow-Headers' do
|
||||||
headers['Access-Control-Allow-Headers'].should == "Content-Type, Authorization, Accept, If-None-Match, If-Modified-Since, X-User-Agent, Travis-API-Version"
|
headers['Access-Control-Allow-Headers'].should == "Content-Type, Authorization, Accept, If-None-Match, If-Modified-Since, X-User-Agent, Travis-API-Version"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'sets Access-Control-Max-Age' do
|
||||||
|
headers['Access-Control-Max-Age'].should == "86400"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user