diff --git a/config/environments/production.rb b/config/environments/production.rb index 5b2ff786..62f9251e 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -101,6 +101,7 @@ ### S3 Configuration ### config.lesson_store = :s3 + config.cloudfront_url = 'https://d1j5ysqdewbwao.cloudfront.net' config.zip_bucket_name = 'dl-prodapp-lessons-zipped' config.s3_bucket_name = 'dl-prodapp-lessons' diff --git a/config/environments/staging.rb b/config/environments/staging.rb index 3347785f..da1b0b54 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -62,6 +62,7 @@ ### S3 Configuration ### config.lesson_store = :s3 + config.cloudfront_url = 'https://dmx80r2ae8pd1.cloudfront.net' config.zip_bucket_name = 'dl-stageapp-lessons-zipped' config.s3_bucket_name = 'dl-stageapp-lessons' diff --git a/lib/s3_proxy.rb b/lib/s3_proxy.rb index 74412d00..892c671c 100644 --- a/lib/s3_proxy.rb +++ b/lib/s3_proxy.rb @@ -8,7 +8,7 @@ def perform_request(env) # use rack proxy for anything hitting our host app at /example_service if use_s3? && request.path =~ %r{^/storylines} - @backend = URI("https://#{s3_bucket_name}.s3-#{s3_region}.amazonaws.com") + @backend = URI(cloudfront_url) # most backends required host set properly, but rack-proxy doesn't set this for you automatically # even when a backend host is passed in via the options @@ -32,11 +32,7 @@ def use_s3? Rails.configuration.lesson_store == :s3 end - def s3_bucket_name - Rails.configuration.s3_bucket_name - end - - def s3_region - Rails.configuration.s3_region + def cloudfront_url + Rails.configuration.cloudfront_url end end