无法从 http 页面显示 https 模式
Trouble showing https modal from http page
我有一个 Rails 3.2.21 应用程序,它需要用户登录才能执行多项操作(例如关注另一个用户)。
问题是我已将 ONLY 登录和注册页面切换为 https;该应用程序的其余部分仍然是 http(在这两个页面上使用 rack-ssl-enforcer gem 到 301 重定向从 http -> https,以防万一)。通过 Ajax 打开模式以显示登录或注册时,它不起作用。在 Rails 日志中它说:
WARNING: Can't verify CSRF token authenticity
并且在 Chrome 中,控制台显示:
Failed to load https://mydomain/signup: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://mydomain' is therefore not allowed access.
代码如下所示。单击 link 关注用户运行以下 jQuery 代码:
$.ajax({
type: "GET",
url: "/follow/" + $(this).data("follow-id")
})
FollowsController
有before_filter :login_required
,ApplicationController
中的login_required
方法是这样的:
def login_required
redirect_to "/signup" and return
end
没有 https 的登录和注册页面,一切正常。当我将它们切换到 https 时,这个问题就出现了。
编辑:
已尝试发布 here 的解决方案,但无济于事。
rack-cors gem 救援。成功了。
我有一个 Rails 3.2.21 应用程序,它需要用户登录才能执行多项操作(例如关注另一个用户)。
问题是我已将 ONLY 登录和注册页面切换为 https;该应用程序的其余部分仍然是 http(在这两个页面上使用 rack-ssl-enforcer gem 到 301 重定向从 http -> https,以防万一)。通过 Ajax 打开模式以显示登录或注册时,它不起作用。在 Rails 日志中它说:
WARNING: Can't verify CSRF token authenticity
并且在 Chrome 中,控制台显示:
Failed to load https://mydomain/signup: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://mydomain' is therefore not allowed access.
代码如下所示。单击 link 关注用户运行以下 jQuery 代码:
$.ajax({
type: "GET",
url: "/follow/" + $(this).data("follow-id")
})
FollowsController
有before_filter :login_required
,ApplicationController
中的login_required
方法是这样的:
def login_required
redirect_to "/signup" and return
end
没有 https 的登录和注册页面,一切正常。当我将它们切换到 https 时,这个问题就出现了。
编辑:
已尝试发布 here 的解决方案,但无济于事。
rack-cors gem 救援。成功了。