Add CORS header in order to access the public API from JavaScript

(I have no idea what I'm doing)
This commit is contained in:
Vencislav Atanasov 2016-11-04 15:34:44 +02:00
parent 4d93de0e21
commit b732aff523
8 changed files with 20 additions and 0 deletions

View File

@ -1,2 +1,7 @@
class Api::ApplicationController < ::ApplicationController
def set_access_control_headers
if request.format.json?
response.headers['Access-Control-Allow-Origin'] = '*'
end
end
end

View File

@ -1,5 +1,6 @@
class Api::EventTypesController < Api::ApplicationController
include ::CurrentConferenceAssigning
include ::PublicApiExposing
before_filter :require_current_conference!
def index

View File

@ -1,5 +1,6 @@
class Api::EventsController < Api::ApplicationController
include ::CurrentConferenceAssigning
include ::PublicApiExposing
before_filter :require_current_conference!
def index

View File

@ -1,5 +1,6 @@
class Api::HallsController < Api::ApplicationController
include ::CurrentConferenceAssigning
include ::PublicApiExposing
before_filter :require_current_conference!
def index

View File

@ -1,5 +1,6 @@
class Api::SlotsController < Api::ApplicationController
include ::CurrentConferenceAssigning
include ::PublicApiExposing
before_filter :require_current_conference!
def index

View File

@ -1,5 +1,6 @@
class Api::SpeakersController < Api::ApplicationController
include ::CurrentConferenceAssigning
include ::PublicApiExposing
before_filter :require_current_conference!
def index

View File

@ -1,5 +1,6 @@
class Api::TracksController < Api::ApplicationController
include ::CurrentConferenceAssigning
include ::PublicApiExposing
before_filter :require_current_conference!
def index

View File

@ -0,0 +1,9 @@
require 'active_support/concern'
module PublicApiExposing
extend ActiveSupport::Concern
included do
before_action :set_access_control_headers
end
end