Skip to content

Instantly share code, notes, and snippets.

@ryanb
Created November 27, 2012 21:38
Show Gist options
  • Save ryanb/4157256 to your computer and use it in GitHub Desktop.
Save ryanb/4157256 to your computer and use it in GitHub Desktop.

Revisions

  1. ryanb created this gist Nov 27, 2012.
    20 changes: 20 additions & 0 deletions development.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    class AssetHeaders
    def initialize(app)
    @app = app
    end

    def call(env)
    request = Rack::Request.new(env)
    response = @app.call(env)
    if request.path =~ /^\/assets\//
    # there maybe a better way to add headers
    response[1]["Access-Control-Allow-Origin"] = "*"
    end
    response
    end
    end

    Railscasts::Application.configure do
    config.middleware.use "AssetHeaders"
    # ...
    end