title: CORS issue: Getting error "No 'Access-Control-Allow-Origin' header is present" when it actually is
body: <p>I doubt the backend serving my app is important, but if you care, I'm using <a href="https://github.com/cyu/rack-cors" rel="noreferrer">rack-cors</a> with a Rails 4.0 app.</p>
  
  <p>Using jQuery, I send my app a <code>PATCH</code> request like so:</p>
  
  <pre><code>$.ajax({
    url: "http://example.com/whatever",
    type: "PATCH",
    data: { something: "something else" }
  })
  </code></pre>
  
  <p>When I trigger this call from Chrome, I see a successful <code>OPTIONS</code> request go out, which returns these headers from my server:</p>
  
  <pre><code>Access-Control-Allow-Credentials:true
  Access-Control-Allow-Headers:accept, content-type
  Access-Control-Allow-Methods:GET, PUT, PATCH, OPTIONS
  Access-Control-Allow-Origin: http://sending-app.localhost:3000
  Access-Control-Expose-Headers:
  Access-Control-Max-Age:15
  </code></pre>
  
  <p>Then I see a <code>PATCH</code> request go out, which throws this error:</p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load <a href="http://example.com/whatever" rel="noreferrer">http://example.com/whatever</a>. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<a href="http://sending-app.localhost:3000" rel="noreferrer">http://sending-app.localhost:3000</a>' is therefore not allowed access. </p>
  </blockquote>
  
  <p>I have tried switching from <code>PATCH</code> to <code>PUT</code> with the same results.</p>
  
  <p>This doesn't make any sense to me. What's going on?</p>
  
  <h3>Update: My config/application.rb</h3>
  
  <p>I thought the headers told the whole story, but since people are confused, here's my <code>config/application.rb</code> file, which is how the rack-cors plugin for Rails is configured:</p>
  
  <pre><code>config.middleware.use Rack::Cors do
    allow do
      origins '*'
      resource '*',
        :headers =&gt; :any,
        :methods =&gt; [:get, :put, :patch, :options],
        :max_age =&gt; 15
    end
  end
  </code></pre>