Created
February 8, 2020 01:20
-
-
Save pmkhoa/4ed29d298b6cc02aa725f6b35f201369 to your computer and use it in GitHub Desktop.
CORS for Sinatra
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before do | |
headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS' | |
headers['Access-Control-Allow-Origin'] = '*' | |
headers['Access-Control-Allow-Headers'] = 'accept, authorization, origin' | |
end | |
options '*' do | |
response.headers['Allow'] = 'HEAD,GET,PUT,DELETE,OPTIONS,POST' | |
response.headers['Access-Control-Allow-Headers'] = 'X-Requested-With, X-HTTP-Method-Override, Content-Type, Cache-Control, Accept' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment