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:
parent
4d93de0e21
commit
b732aff523
|
@ -1,2 +1,7 @@
|
||||||
class Api::ApplicationController < ::ApplicationController
|
class Api::ApplicationController < ::ApplicationController
|
||||||
|
def set_access_control_headers
|
||||||
|
if request.format.json?
|
||||||
|
response.headers['Access-Control-Allow-Origin'] = '*'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
class Api::EventTypesController < Api::ApplicationController
|
class Api::EventTypesController < Api::ApplicationController
|
||||||
include ::CurrentConferenceAssigning
|
include ::CurrentConferenceAssigning
|
||||||
|
include ::PublicApiExposing
|
||||||
before_filter :require_current_conference!
|
before_filter :require_current_conference!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
class Api::EventsController < Api::ApplicationController
|
class Api::EventsController < Api::ApplicationController
|
||||||
include ::CurrentConferenceAssigning
|
include ::CurrentConferenceAssigning
|
||||||
|
include ::PublicApiExposing
|
||||||
before_filter :require_current_conference!
|
before_filter :require_current_conference!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
class Api::HallsController < Api::ApplicationController
|
class Api::HallsController < Api::ApplicationController
|
||||||
include ::CurrentConferenceAssigning
|
include ::CurrentConferenceAssigning
|
||||||
|
include ::PublicApiExposing
|
||||||
before_filter :require_current_conference!
|
before_filter :require_current_conference!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
class Api::SlotsController < Api::ApplicationController
|
class Api::SlotsController < Api::ApplicationController
|
||||||
include ::CurrentConferenceAssigning
|
include ::CurrentConferenceAssigning
|
||||||
|
include ::PublicApiExposing
|
||||||
before_filter :require_current_conference!
|
before_filter :require_current_conference!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
class Api::SpeakersController < Api::ApplicationController
|
class Api::SpeakersController < Api::ApplicationController
|
||||||
include ::CurrentConferenceAssigning
|
include ::CurrentConferenceAssigning
|
||||||
|
include ::PublicApiExposing
|
||||||
before_filter :require_current_conference!
|
before_filter :require_current_conference!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
class Api::TracksController < Api::ApplicationController
|
class Api::TracksController < Api::ApplicationController
|
||||||
include ::CurrentConferenceAssigning
|
include ::CurrentConferenceAssigning
|
||||||
|
include ::PublicApiExposing
|
||||||
before_filter :require_current_conference!
|
before_filter :require_current_conference!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
require 'active_support/concern'
|
||||||
|
|
||||||
|
module PublicApiExposing
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
included do
|
||||||
|
before_action :set_access_control_headers
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue