Sha256: f298e85643f4d3fcf36a4763b040126b656e38c5dce8dea88a77ff6921d943b7

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

require 'rack/cors'
require 'jsonapi-serializers'
require 'groupdate'
require 'net/http'
require 'useragent'
require 'jwt'
require 'bcrypt'
require_relative 'bootstraper'
require_relative 'collection'

module ForestLiana
  class Engine < ::Rails::Engine
    isolate_namespace ForestLiana

    def configure_forest_cors
      return unless ForestLiana.inject_forest_cors

      rack_cors_class = Rack::Cors
      rack_cors_class = 'Rack::Cors' if Rails::VERSION::MAJOR < 5

      config.middleware.insert_before 0, rack_cors_class do
        allow do
          hostnames = ['localhost:4200', 'app.forestadmin.com',
                       'www.forestadmin.com']
          hostnames += ENV['CORS_ORIGINS'].split(',') if ENV['CORS_ORIGINS']

          origins hostnames
          resource '*', headers: :any, methods: :any
        end
      end
    end

    config.after_initialize do |app|
      unless Rails.env.test?
        configure_forest_cors
        app.eager_load!
        Bootstraper.new(app).perform
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
forest_liana-1.4.3 lib/forest_liana/engine.rb
forest_liana-1.4.2 lib/forest_liana/engine.rb
forest_liana-1.4.1 lib/forest_liana/engine.rb
forest_liana-1.4.0 lib/forest_liana/engine.rb
forest_liana-1.3.53 lib/forest_liana/engine.rb
forest_liana-1.3.52 lib/forest_liana/engine.rb
forest_liana-1.3.51 lib/forest_liana/engine.rb
forest_liana-1.3.50 lib/forest_liana/engine.rb