#Rails assets won't load when using nixpacks
6 messages · Page 1 of 1 (latest)
The img tag can't find the image for example. The same happens for CSS and JS files
The build logs
config.serve_static_assets configures Rails itself to serve static assets. Defaults to true, but in the production environment is turned off as the server software (e.g. Nginx or Apache) used to run the application should serve static assets instead. Unlike the default setting set this to true when running (absolutely not recommended!) or testing your app in production mode using WEBrick. Otherwise you won´t be able use page caching and requests for files that exist regularly under the public directory will anyway hit your Rails app.
Let's see if it's caused by this config
# 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?
Fixed it by adding RAILS_SERVE_STATIC_FILES environment variable