gist JS

Thursday, September 11, 2014

CORS for Rails / Heroku & Cloudfront (for dummies)

So starting today all your fonts don't load. Because CORS.

No 'Access-Control-Allow-Origin' header is present on the requested resource.

Here's what to do.

1) Remember your CloudFront password.

2) Edit your behavior


3) Forwarding headers -> whitelist

4) Add "Origin"

5) Add rack-cors to Gemfile

gem 'rack-cors'

6) Add stuff to config.ru

require 'rack/cors'
use Rack::Cors do

  # allow all origins in development
  allow do
    origins '*'
    resource '*',
        :headers => :any,
        :methods => [:get, :post, :delete, :put, :options]

7) Deploy

8) Try to forget about CORS

Did that work? Why not try my tool ForceRank.it, a prioritization tool for product teams that lets you rank choices. It even lets you import a Trello board!