Sha256: a4c09af2c12ece45836f22c66d3f6967243d3cf0aa20c47460a98b0146a73c36
Contents?: true
Size: 818 Bytes
Versions: 4
Compression:
Stored size: 818 Bytes
Contents
module ElocalApiSupport::EnableCors extend ActiveSupport::Concern included do cors_allow_all before_filter :enable_cors end module ClassMethods attr_accessor :cors_allow_origin, :cors_allow_methods, :cors_allow_headers def cors_allow_all self.cors_allow_origin = '*' self.cors_allow_methods = %w(GET POST PUT DELETE).join(',') self.cors_allow_headers = %w(Origin Accept Content-Type X-Requested-With X-XSRF-Token).join(',') end end def enable_cors response.headers['Access-Control-Allow-Origin'] = self.class.cors_allow_origin response.headers['Access-Control-Allow-Methods'] = self.class.cors_allow_methods response.headers['Access-Control-Allow-Headers'] = self.class.cors_allow_headers head(:ok) if request.request_method == 'OPTIONS' end end
Version data entries
4 entries across 4 versions & 1 rubygems