Search code examples
locomotivecms

LocomotiveCMS 2.2.3 issue assets not loading https


I'm hosting a locomotiveCMS engine on heroku. I just upgraded the engine to 2.2.3 everything worked fine, except that now all assets are failing to load. After I looked at the source code I saw that all assets (like css, js etc) are referenced via "https" to my s3 bucket and thus not working.

I'm using the liquid tags like "{{ "main" | stylesheet_tag }}" and don't know why they resolve to "https"

Thanks Nick


Solution

  • I fixed it by adding these 2 lines to following to carrierwave.rb:

    config.asset_host = 'http://.s3.amazonaws.com'

    config.fog_public = true

    CarrierWave.configure do |config|
    
      config.cache_dir = File.join(Rails.root, 'tmp', 'uploads')
    
      case Rails.env.to_sym
    
      when :development
        config.storage = :file
        config.root = File.join(Rails.root, 'public')
    
      when :production
        # the following configuration works for Amazon S3
        config.storage          = :fog
        config.fog_credentials  = {
          :provider                 => 'AWS',
          :aws_access_key_id        => ENV['S3_KEY_ID'],
          :aws_secret_access_key    => ENV['S3_SECRET_KEY'],
          :region                   => ENV['S3_BUCKET_REGION']
        }
        config.fog_directory    = ENV['S3_BUCKET']
        config.asset_host     = 'http://<my-bucket-name>.s3.amazonaws.com'
        config.fog_public = true
      else
        # settings for the local filesystem
        config.storage = :file
        config.root = File.join(Rails.root, 'public')
      end
    
    end