【问题标题】:livereload rails 7 and incorrect (X-Content-Type-Options: nosniff)livereload rails 7 不正确(X-Content-Type-Options:nosniff)
【发布时间】:2022-11-23 15:43:26
【问题描述】:

我使用宝石:

gem 'guard'
gem 'guard-livereload', require: false
gem 'rack-livereload'
gem 'rb-fsevent',       require: false

并像在 Rails 6 中一样执行 bundle exec guard(没有问题)但是对于我的 Rails 7 应用程序,当我保存 CSS 并尝试重新加载它时出现错误:

“http://localhost:3000/seances”上的资源由于不正确的 MIME 类型(“text/html”)不正确(X-Content-Type-Options:nosniff)而被阻止。

我所有的 css 都被删除,但新的 css 不适用。

我该如何解决这个问题?

【问题讨论】:

    标签: ruby-on-rails mime-types livereload ruby-on-rails-7 x-content-type-options


    【解决方案1】:

    确保为您的 css 资源提供服务的 Web 服务器在 Content-type 标头中包含正确的 mime 类型(应该是 text/css,而不是 text/html)

    【讨论】:

    • 你如何用 Rails 7 做到这一点?
    【解决方案2】:

    看起来这有时是 config.assets.digest 的默认开发轨道配置的问题,请尝试在 config/development.rb 中将其设置为 false

    config.assets.digest = false
    

    来源:https://github.com/guard/guard-livereload/issues/193

    【讨论】:

      猜你喜欢
      • 2017-11-23
      • 2020-10-14
      • 2010-12-17
      • 1970-01-01
      • 2019-09-11
      • 1970-01-01
      • 1970-01-01
      • 2019-02-28
      • 2023-01-11
      相关资源
      最近更新 更多