ruby on rails - ActionController::InvalidCrossOriginRequest exception due to bingbots -


i have rails applications loading comments using ajax after page load.

class commentscontroller < applicationcontroller   respond_to :js    def index     @comments = comments.all     respond_with @comments   end end 

it working expected. bingbot trying access url leads

an actioncontroller::invalidcrossoriginrequest occurred in comments#index: security warning: embedded tag on site requested protected javascript. if know you're doing, go ahead , disable forgery protection on action permit cross-origin javascript embedding.

like coming url's responding js format.

i know rack-cors, allowing cross side script access, here not.

app/views/comments/index.js.erb

$('.comments_container').html("<%=j render 'comments' %>"); 

comments.js

jquery(function() {   return $.ajax({     url: $('.comments_container').data('url')({       datatype: "script"     })   }); }); 

assuming need cors(cross-origin resource sharing), getting error because cors policy default "denying" every direct xhr access.

you can use rack-cors gem https://github.com/cyu/rack-cors avoid this. hope help!


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -