问题描述
我做了一个rails / solidus应用程序的git clone,它在我的本地计算机上运行良好,但是在Production中进行部署后,CSS和JS无法正常工作。我使用Rails 6,webpack和链轮。
资产管道的请求已完成,但是当我在DOM中查看响应时,响应为“找不到404”
GEThttps://marguery.cLeverapps.io/assets/application-b31b32abb971f17a524d21ec2a0da1c8e278eeec1494078c645d0b78c1421333.css[HTTP/1.1 404 Not Found 131ms]
GEThttps://marguery.cLeverapps.io/packs/js/application-8a33c36bccf807dbd76b.js[HTTP/1.1 404 Not Found 320ms]
当我尝试连接商店时,出现错误
"Can't verify CSRF token authenticity"
您可以通过此链接查看 https://marguery.cleverapps.io/
似乎指纹是错误的?我认为某个地方有以前应用程序的一些旧数据,但是我找不到在哪里以及如何重新初始化它
对于我的第一次部署,
ArgumentError:“生产”环境缺少secret_key_base
,请使用rails credentials:edit
设置此字符串
所以我已经删除了现有的certificate.yml.enc并运行:rails credentials:edit
创建一个新的凭据。
该部署已获授权。
我尝试过:
我在我的语言环境计算机上进行了操作。
RAILS_ENV=production rails assets:precompile
ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
/mnt/882A716B2A7156E2/0-Projets/maisonmarguery2/maisonmarguery/config/environment.rb:5:in `<main>'
/mnt/882A716B2A7156E2/0-Projets/maisonmarguery2/maisonmarguery/bin/rails:9:in `<top (required)>'
/mnt/882A716B2A7156E2/0-Projets/maisonmarguery2/maisonmarguery/bin/spring:15:in `<top (required)>'
./bin/rails:3:in `load'
./bin/rails:3:in `<main>'
我在服务器端做了
rails assets:precompile
yarn install v1.22.4
[1/4] Resolving packages...
success Already up-to-date.
Done in 1.00s.
Everything's up-to-date. nothing to do
我的配置/环境/production.rb
Rails.application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress CSS using a preprocessor.
config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'x-accel-redirect' # for Nginx
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
config.log_level = :debug
config.log_tags = [ :request_id ]
config.action_mailer.perform_caching = false
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end
我的宝石文件
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.6.5'
# Bundle edge Rails instead: gem 'rails',github: 'rails/rails'
gem 'rails','~> 6.0.3','>= 6.0.3.2'
# Use sqlite3 as the database for Active Record
gem 'railties','>= 5.1'
gem 'sqlite3','~> 1.4'
gem 'pg'
gem 'open_solidus_cloudinary',git: 'https://github.com/Berlimioz/open_solidus_cloudinary.git'
# Use Puma as the app server
gem 'puma','~> 4.1'
# Use SCSS for stylesheets
gem 'sassc-rails'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker','~> 4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks','~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder','~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis','~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt','~> 3.1.7'
gem 'autoprefixer-rails'
gem 'font-awesome-sass','~> 5.6.1'
gem 'simple_form'
gem 'cloudinary','~> 1.1.7'
gem 'google-analytics-rails','~> 1.1','>= 1.1.1'
gem 'sitemap_generator'
gem 'solidus'
gem 'solidus_auth_devise'
gem 'solidus_i18n','~> 2.0'
gem 'rails-i18n','> 5.0'
gem 'kaminari-i18n','~> 0.5.0'
gem 'routing-filter','~> 0.6.0'
gem 'sprockets','= 3.7.2'
gem 'dotenv-rails'
# Use Active Storage variant
# gem 'image_processing','~> 1.2'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap','>= 1.4.2',require: false
group :development,:test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug',platforms: [:mri,:mingw,:x64_mingw]
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console','>= 3.3.0'
gem 'listen','~> 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen','~> 2.0.0'
gem 'guard-livereload','~> 2.5',require: false
gem 'rack-livereload'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara','>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of web drivers to run system tests with browsers
gem 'webdrivers'
end
# Windows does not include zoneinfo files,so bundle the tzinfo-data gem
gem 'tzinfo-data',platforms: [:mingw,:mswin,:x64_mingw,:jruby]
任何帮助或想法将不胜感激!谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)