ericallam / font_assets

Helps with serving font assets with Rails 3.1
137 stars 79 forks source link

Does this gem work with heroku? #13

Open SubaruWRX55 opened 11 years ago

SubaruWRX55 commented 11 years ago

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

ericallam commented 11 years ago

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 notifications@github.com 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.

SubaruWRX55 commented 11 years ago

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

SubaruWRX55 commented 11 years ago

~/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

ericallam commented 11 years ago

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 notifications@github.com 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.

SubaruWRX55 commented 11 years ago

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

SubaruWRX55 commented 11 years ago

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

reconbot commented 11 years ago

Looks like pr #14 fixes this issue.