ActionController::RoutingError Маршрут не соответствует [GET] и [OPTION] для /cloudfoundryapplication

Я использую Rails 5.1.3 с Puma на Pivotal Web Services. После обновления до этой версии с Rails 4 я вижу в журналах следующие ошибки:

1. ActionController::RoutingError (No route matches [GET] "/cloudfoundryapplication")
2. ActionController::RoutingError (No route matches [OPTION] "/cloudfoundryapplication")

Я не могу найти никаких подробностей о «/cloudfoundryapplication» в Pivotal, но, поскольку это внешнее приложение, я подумал, что оно может быть связано с общим доступом к ресурсам между источниками (CORS). Затем я использовал гем «rack-cors», чтобы попытаться решить проблему. В результате исчезли ошибки [OPTION], но не ошибки [GET].

Вот мой config/application.rb:

require_relative 'boot'

require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"
require 'pdfkit'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.

Bundler.require(*Rails.groups)

module MyFaro
  class Application < Rails::Application
    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 5.1

    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    config.time_zone = 'Brussels'

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    #config.i18n.load_path = Dir[Rails.root.join('config', 'locales', '*.{rb,yml}').to_s]
    config.i18n.default_locale = :nl

    #config.skylight.probes += %w(mongoid mongo)

    config.middleware.use PDFKit::Middleware, {:print_media_type => true}, :only => %r[/print_story]

    config.after_initialize do
      ApplicationController.helpers.cache_set_look_up_hash
      ApplicationController.helpers.cache_set_system_parameter_hash
    end
  end
end

и мой config/environments/production.rb:

Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  #CORS
  config.middleware.insert_before 0, Rack::Cors do
    allow do
      origins '*'
      resource '*', :headers => :any, :methods => [:get, :post, :options]
    end
  end

  # Code is not reloaded between requests.
  config.cache_classes = true

  # Eager load code on boot. This eager loads most of Rails and
  # your application in memory, allowing both threaded web servers
  # and those relying on copy on write to perform better.
  # Rake tasks automatically ignore this option for performance.
  config.eager_load = true

  # Full error reports are disabled and caching is turned on.
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.cache_store = :memory_store

  # Attempt to read encrypted secrets from `config/secrets.yml.enc`.
  # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
  # `config/secrets.yml.key`.
  config.read_encrypted_secrets = true

  # Disable serving static files from the `/public` folder by default since
  # Apache or NGINX already handles this.
  config.public_file_server.enabled = true

  # Compress JavaScripts and CSS.
  config.assets.js_compressor = :uglifier
  # config.assets.css_compressor = :sass

  # Do not fallback to assets pipeline if a precompiled asset is missed.
  config.assets.compile = true

  # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb

  # Enable serving of images, stylesheets, and JavaScripts from an asset server.
  # config.action_controller.asset_host = 'http://assets.example.com'

  # 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

  # Mount Action Cable outside main process or domain
  # config.action_cable.mount_path = nil
  # config.action_cable.url = 'wss://example.com/cable'
  # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]

  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
   config.force_ssl = true

  # Use the lowest log level to ensure availability of diagnostic information
  # when problems arise.
  config.log_level = :error

  # Prepend all log lines with the following tags.
  config.log_tags = [ :request_id ]

  # Use a different cache store in production.
  # config.cache_store = :mem_cache_store

  # Use a real queuing backend for Active Job (and separate queues per environment)
  # config.active_job.queue_adapter     = :resque
  # config.active_job.queue_name_prefix = "my_faro_#{Rails.env}"
  config.action_mailer.perform_caching = false

  # Ignore bad email addresses and do not raise email delivery errors.
  # Set this to true and configure the email server for immediate delivery to raise delivery errors.
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.perform_deliveries = true
  config.action_mailer.default_url_options = { host: 'http://myfaro.cfapps.io/'}
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
      address: 'smtp.mailgun.org',
      port: 587,
      authentication: 'plain',
      #domain: 'sandboxe3e6f1cfc3d34efc8dba23c1a1eaff8b.mailgun.org',
      domain: 'mg.myfaro.be',
      #user_name: '[email protected]',
      user_name: '[email protected]',
      #password: '25c695256391ca3e9f6c6bb1dd9f622f'
      password: 'f1d6d58994362f084cc2ecac0e46256c'
  }
  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  # the I18n.default_locale when a translation cannot be found).
  config.i18n.fallbacks = true
  config.i18n.available_locales = [:en,:nl,:fr,:de]

  # Send deprecation notices to registered listeners.
  config.active_support.deprecation = :notify

  # Use default logging formatter so that PID and timestamp are not suppressed.
  config.log_formatter = ::Logger::Formatter.new

  # Use a different logger for distributed setups.
  # require 'syslog/logger'
  # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')

  if ENV["RAILS_LOG_TO_STDOUT"].present?
    logger           = ActiveSupport::Logger.new(STDOUT)
    logger.formatter = config.log_formatter
    config.logger    = ActiveSupport::TaggedLogging.new(logger)
  end

end

person user8737928    schedule 23.11.2017    source источник
comment
Сообщается об одной проблеме с тем же github.com/pivotal-cf/pcfdev/issues/. 253   -  person Deepak Mahakale    schedule 23.11.2017


Ответы (2)


Мне ответила служба поддержки Pivotal.

Диспетчер приложений Pivotal Web Services использует конечную точку /cloudfoundryapplication в качестве корня для интеграции Spring Boot Actuator. Он вызывает эту конечную точку для приложения, когда вы просматриваете приложение в пользовательском интерфейсе диспетчера приложений, независимо от того, настроили ли вы конечные точки Spring Boot Actuator для диспетчера приложений.

Таким образом, для приложений, не использующих конечные точки Spring Boot Actuator, эти ошибки появляются, но только при использовании графического интерфейса диспетчера приложений.

Это как у Шредингеровского кота света в холодильнике: если не смотреть, то ошибки не появляются. Я проверил журналы через CLI, и действительно, ошибок нет вообще.

person user8737928    schedule 24.11.2017

Заимствуем строку из config/routes.rb приложения:

match '/cloudfoundryapplication', to: proc { [200, {}, ['']] }, via: %i[get options]
person olleolleolle    schedule 17.09.2019