在我的Rails 4应用程序中,我before_action要求用户登录,如下所示:
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :require_login
def require_login
unless logged_in?
flash[:alert] = "You must be logged in to access this section."
redirect_to login_path
end
end
def logged_in?
# more logic
end
end
Run Code Online (Sandbox Code Playgroud)
当我example.com在没有登录的情况下访问时,我会example.com/login按预期重定向到.但是,我在控制台中看到此错误:
The page at 'https://example.com/login' was loaded over HTTPS, but displayed
insecure content from 'http://example.com/login': this content should also
be loaded over HTTPS.
Run Code Online (Sandbox Code Playgroud)
网络选项卡似乎表明我redirect_to指的是HTTP而不是HTTPS.当它命中HTTP时,它会自动重定向到HTTPS.
Request URL:http://example.com/login
Request Method:GET
Status …Run Code Online (Sandbox Code Playgroud)