谷歌浏览器中有一个奇怪的行为,这个问题也有描述:rails redirects to 'data:,'
当创建新资源并且我的 Controller 重定向到显示操作时, chrome 使用 'data:,'
开始加载空白页面在地址栏中 .提出上述问题的作者的答复如下:
这是一项安全功能,新页面的 HTML 内容与 Chrome 阻止的提交表单的 HTML 内容相匹配。
然而,没有解释如何修复它。该行为仅存在于 Chrome 浏览器中。
最佳答案
我一直在谷歌搜索,发现在 Rails 4.0 中使用 iframe 编辑帖子会导致重定向到“data:”
Rails 4 now sets the X-XSS-Protection header for all requests, so the iframe trips up the XSS protection in Chrome after a form submit. (https://github.com/elektronaut/sugar/issues/41#issuecomment-25987368)
解决方案,将其添加到您的 Controller :
before_filter :disable_xss_protection
protected
def disable_xss_protection
# Disabling this is probably not a good idea,
# but the header causes Chrome to choke when being
# redirected back after a submit and the page contains an iframe.
response.headers['X-XSS-Protection'] = "0"
end
关于ruby-on-rails - Rails 4 在 Chrome 中重定向到 'data:,',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19106111/