在生产模式下启动应用程序时,资产(css + js)无法正确加载。
我进入浏览器的控制台net::ERR_ABORTED 404 (Not Found)
或Rails日志ActionController::RoutingError (No route matches [GET] "/packs/js/application-51bdb73d26ac893c3407.js"):
我制作了rake assets:precompile
并且还打开config.assets.compile = true
了environment / production.rb,但是结果相同
对于生产模式,我使用了相同的应用程序和相同的目录,只是将其添加-e production
为rails server
命令的参数
似乎您应该将RAILS_SERVE_STATIC_FILES
环境变量设置为true
建议是基于我在解决相同问题时发现的此问题评论
这只会影响以下位置的配置config/environments/production.rb
:
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句