title: Strophe-Ejabberd-Rails: Access-Control-Allow-Origin Error
body: <p>I am getting the CORS error while trying to connect <code>xmpp server, ejabberd</code> running on port <code>5280</code> using <code>Strophe</code> on <code>Rails app</code>.</p>
  
  <p><code>XMLHttpRequest cannot load http://localhost:5280/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.</code></p>
  
  <p>I tried the following ways to resolve the issue.</p>
  
  <p>=> enabled cors for all domains in application.rb</p>
  
  <pre><code>config.middleware.use Rack::Cors do
    allow do
      origins '*'
      resource '*', :headers =&gt; :any, :methods =&gt; [:get, :post, :options]
    end
  end
  </code></pre>
  
  <p>=> Added <code>strophe.flxhr.min.js</code> but it gave another error <code>flensed is not
      defined</code>, which I wasn't able to resolve.</p>
  
  <p>How to resolve this error.</p>