15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/forest_liana/engine.rb', line 15
def configure_forest_cors
begin
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', /\A.*\.forestadmin\.com\z/]
hostnames += ENV['CORS_ORIGINS'].split(',') if ENV['CORS_ORIGINS']
origins hostnames
resource '*', headers: :any, methods: :any
end
end
nil
rescue => exception
exception
end
end
|