font_assets icon indicating copy to clipboard operation
font_assets copied to clipboard

Does this gem work with heroku?

Open SubaruWRX55 opened this issue 12 years ago • 7 comments

I was able to get this gem working in my local dev env, but origin headers are not inserted when I upload to heroku. I'm running rails 3.2

SubaruWRX55 avatar Feb 07 '13 08:02 SubaruWRX55

It should, we use it on codeschool.com and our course apps. Are you configuring the gem with the origin in your config/environments/production.rb? Like so:

config.font_assets.origin = "http://example.com"

On Feb 7, 2013, at 3:23 AM, SubaruWRX55 [email protected] wrote:

I was able to get this gem working in my local dev env, but origin headers are not inserted when I upload to heroku. I'm running rails 3.2

— Reply to this email directly or view it on GitHub.

ericallam avatar Feb 07 '13 16:02 ericallam

Looks like as soon as I run assets:precompile, it stops adding the origin header.

SubaruWRX55 avatar Feb 07 '13 19:02 SubaruWRX55

~/testOriginal [master]$ curl -I localhost:3000/assets/fa.woff HTTP/1.1 500 Internal Server Error Content-Type: application/font-woff Content-Length: 8504 X-Request-Id: fa67625df9c05085a4d2da1d1774683a X-Runtime: 0.344087 Access-Control-Allow-Origin: * Access-Control-Allow-Methods: GET Access-Control-Allow-Headers: x-requested-with Access-Control-Max-Age: 3628800 Server: WEBrick/1.3.1 (Ruby/1.9.3/2012-12-25) Date: Thu, 07 Feb 2013 19:08:30 GMT Connection: Keep-Alive

~/testOriginal [master]$ rake assets:precompile /home/user/.rvm/rubies/ruby-1.9.3-p362/bin/ruby /home/user/.rvm/gems/ruby-1.9.3-p362@global/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets

~/testOriginal [master]$ curl -I localhost:3000/assets/fa.woff HTTP/1.1 200 OK Last-Modified: Thu, 07 Feb 2013 03:05:49 GMT Content-Type: application/font-woff Content-Length: 31840 Server: WEBrick/1.3.1 (Ruby/1.9.3/2012-12-25) Date: Thu, 07 Feb 2013 19:08:58 GMT Connection: Keep-Alive

SubaruWRX55 avatar Feb 07 '13 19:02 SubaruWRX55

Ah. That's probably because the asset is then served from public/ in production, and no longer hits the rails app. Since it doesn't hit the rails app, it won't be caught by the font_assets middleware to respond with the Access-Control headers. On codeschool.com and our courses, we don't use precompile (we let the CDN serve the assets, hence the whole point have this gem)

On Feb 7, 2013, at 2:06 PM, SubaruWRX55 [email protected] wrote:

Looks like as soon as I run assets:precompile, it stops adding the origin header.

— Reply to this email directly or view it on GitHub.

ericallam avatar Feb 07 '13 19:02 ericallam

can you share how you disable precompile on heroku? are you on cedar stack?

SubaruWRX55 avatar Feb 07 '13 19:02 SubaruWRX55

i got it. here is what i did

  1. added a blank file in public/assets/manifest.yml
  2. in production.rb change one line: config.assets.compile = true

SubaruWRX55 avatar Feb 07 '13 21:02 SubaruWRX55

Looks like pr #14 fixes this issue.

reconbot avatar Oct 23 '13 14:10 reconbot