title: ActionController::InvalidCrossOriginRequest exception due to bingbots
body: <p>I have rails applications where I am loading comments using Ajax after page load.</p>
  
  <pre><code>class CommentsController &lt; ApplicationController
    respond_to :js
  
    def index
      @comments = Comments.all
      respond_with @comments
    end
  end
  </code></pre>
  
  <p>It is working as expected. But bingbot is trying to access this url with which it leads to </p>
  
  <p><strong><em>An ActionController::InvalidCrossOriginRequest occurred in comments#index:</strong>
       Security warning: an embedded  tag on another site requested protected JavaScript. If you know what you're doing, go ahead and disable forgery protection on this action to permit cross-origin JavaScript embedding.</em></p>
  
  <p>like that it is coming for all url's which are only responding to js format.</p>
  
  <p>I know about <a href="https://github.com/cyu/rack-cors" rel="nofollow">rack-cors</a>, but it is for allowing cross side script access, but here it is not.</p>
  
  <p><strong>app/views/comments/index.js.erb</strong></p>
  
  <pre><code>$('.comments_container').html("&lt;%=j render 'comments' %&gt;");
  </code></pre>
  
  <p><strong>comments.js</strong></p>
  
  <pre><code>jQuery(function() {
    return $.ajax({
      url: $('.comments_container').data('url')({
        dataType: "script"
      })
    });
  });
  </code></pre>