簡體   English   中英

SSL 無法建立安全連接 - 在 Heroku 中使用 Devise 的 Rails 6 應用程序

[英]SSL cannot establish secure connection - with Rails 6 app using Devise in Heroku

正如標題所說,我有一個在 Heroku 中運行的 Rails 6 應用程序,具有 Heroku 提供的自動 SSL 證書。 一切正常,我可以訪問任何頁面,它使https工作正常。 但是,有一個例外:當用戶注冊並收到 email 確認時,由於某種原因無法單擊鏈接(請參閱下面的截圖),即使您將鏈接復制並粘貼到新標簽中也會發生同樣的情況, 當然。

  • Ruby版本:2.7.1p83
  • 導軌版本:6.0.3.1

Safari 截圖 Firefox: 在此處輸入圖像描述

這是我在嘗試訪問 url https://my_domain.com/users/confirmation?confirmation_token=foobar時得到的。

我的environments/production.rb有這些設置:

Rails.application.configure do
  # a few more non important things, and then:
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = true
  config.action_mailer.smtp_settings = {
    :user_name => ENV['SENDGRID_USERNAME'],
    :password => ENV['SENDGRID_PASSWORD'],
    :domain => 'my_domain.com',
    :address => 'smtp.sendgrid.net',
    :port => 587,
    :authentication => :plain,
    :enable_starttls_auto => true
  }


  config.force_ssl = true
  config.action_mailer.default_url_options = { :host => 'my_domain.com' }
end

這就是它在 Heroku 中的樣子:

在此處輸入圖像描述

我有 Devise 的這些路線:

Rails.application.routes.draw do
  devise_for :users, controllers: { registrations: 'users/registrations',
                                    confirmations: 'users/confirmations' }
  authenticated :user do
    root to: "depots#index", as: :authenticated_root
  end

  root to: "public/welcome#index"
end

controller 看起來像這樣:

class Users::ConfirmationsController < Devise::ConfirmationsController
  def after_confirmation_path_for(resource_name, resource)
    sign_in(resource)
    authenticated_root_path
  end
end

你們有什么想法可能是錯的嗎? 如果沒有,關於如何解決這個問題的任何建議?

2020 年 8 月 4 日更新:

I had added this redirect to my domain but even though it works redirecting from grownis.com to www.grownis.com it doesn't for https://grownis.com

在此處輸入圖像描述

您的證書不是通配符證書。 請檢查此鏈接。

https://grownis.com/

確認鏈接為https://grownis.com/users/confirmation?confirmation_token=CONRIMATION_TOKEN

您需要從非 www 重定向到 www 或購買通配符證書。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM