Làm cách nào để ngăn Google gây ra lỗi này trong khi thu thập dữ liệu trang web? Tôi không quan tâm đến việc tắt "protect_from_forgery" trừ khi nó an toàn để làm như vậy.Googlebot gây ra Yêu cầu xuất xứ chéo không hợp lệ (COR) trên Rails 4.1
[fyi] method=GET path=/users format=*/* controller=users action=show status=200 duration=690.32 view=428.25 db=253.06 time= host= user= user_agent=Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) session= params={""}()
[hmm] Security warning: an embedded <script> 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. (pid:)
[fyi] method=GET path=/users/123/flag format=*/* controller=users action=flag status=500 error='ActionController::InvalidCrossOriginRequest:Security warning: an embedded <script> 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.' duration=26.50 time= host= user= user_agent= session= params= (pid)
[omg] ActionController::InvalidCrossOriginRequest (Security warning: an embedded <script> 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.):
actionpack (4.1.4) lib/action_controller/metal/request_forgery_protection.rb:217:in `verify_same_origin_request'
Bộ điều khiển đáp ứng với điều này
respond_to do |format|
format.js { render template: 'users/flag', layout: "some_layout" }
end
Tôi không thể để tái tạo lỗi và nó dường như làm việc tốt khi tôi làm điều đó thông qua trình duyệt của tôi
Cho đến nay tôi đã xem xét các tài nguyên sau đây nhưng hầu hết dường như chỉ đề nghị chuyển hướng CSRF một cách mù quáng hoặc không được trả lời.
- Using layout specific javascript in comfy leads to InvalidCrossOriginRequest
- Invalid Cross Origin Request After Upgrading to Rails 4.1
- How to avoid ActionController::InvalidCrossOriginRequest exception?
- Googlebot asks for png and then my whole Heroku site crashes. What is going on?
- https://github.com/rails/rails/pull/13345
- http://myownpirateradio.com/tag/rails-authentication-token/
- https://gist.github.com/aishek/8535082
- Why does Google prepend while(1); to their JSON responses?
- http://www.tsheffler.com/blog/?p=428
- http://edgeapi.rubyonrails.org/classes/ActionController/RequestForgeryProtection.html
Để làm rõ: Hành động cần được bảo vệ từ CSRF, Nhưng tôi muốn ngăn chặn Google thu thập thông tin hay tạo ra một lỗi thu thập thông tin trang. Tức là.) Tôi muốn Cảnh báo bảo mật dương tính giả biến mất mà không thực sự ảnh hưởng đến các tính năng bảo mật của tôi.
Đặt hàng quan trọng ở đây. format.html phải đến trước format.js trong khối respond_to. – sma
Tôi đang chạy vào cùng một vấn đề này, và các bước để tái sản xuất được mô tả trong giải pháp không làm việc cho tôi cho đến khi tôi thay đổi tiêu đề thành '-H 'Accept: */*" ', tại thời điểm này tôi có thể tái tạo lỗi. –