X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/333402104e6b7a163bf3f8483a928dbe571b5c2c..c3695bc7282996d66fb1922d7971aa86fb497968:/services/api/app/controllers/application_controller.rb diff --git a/services/api/app/controllers/application_controller.rb b/services/api/app/controllers/application_controller.rb index 459adff3a0..54d5adb439 100644 --- a/services/api/app/controllers/application_controller.rb +++ b/services/api/app/controllers/application_controller.rb @@ -27,6 +27,7 @@ class ApplicationController < ActionController::Base ERROR_ACTIONS = [:render_error, :render_not_found] + before_filter :set_cors_headers before_filter :respond_with_json_by_default before_filter :remote_ip before_filter :load_read_auths @@ -346,6 +347,13 @@ class ApplicationController < ActionController::Base end end + def set_cors_headers + response.headers['Access-Control-Allow-Origin'] = '*' + response.headers['Access-Control-Allow-Methods'] = 'GET, HEAD, PUT, POST, DELETE' + response.headers['Access-Control-Allow-Headers'] = 'Authorization' + response.headers['Access-Control-Max-Age'] = '86486400' + end + def respond_with_json_by_default html_index = request.accepts.index(Mime::HTML) if html_index.nil? or request.accepts[0...html_index].include?(Mime::JSON)