设计 DELETE /users/sign_out returns 状态 204 并且不重定向?
Devise DELETE /users/sign_out returns status 204 and doesn't redirect?
我想知道为什么当我使用 Fetch API 调用设置了 redirect: 'follow'
的注销端点时没有任何反应。
我的简单 React 组件:
<a href="users/sign_out" onClick={this.handleSignOutClick}>Sign Out</a>
我的事件处理程序:
handleSignOutClick (event) {
event.preventDefault();
fetch('/users/sign_out', {
method: 'DELETE',
mode: 'cors',
credentials: 'include',
redirect: 'follow',
});
}
在我的 ApplicationController 中:
def after_sign_in_path_for(resource)
resource.referrer
end
想知道是不是因为我使用 Fetch API 的方式不对?我能够在成功登录时重定向到一个页面。
我不知道你可以在锚点中删除。检查默认 sign_out 按钮后,我使用了
<a href="/users/sign_out" data-method="delete" rel="nofollow">Sign Out</a>
我想知道为什么当我使用 Fetch API 调用设置了 redirect: 'follow'
的注销端点时没有任何反应。
我的简单 React 组件:
<a href="users/sign_out" onClick={this.handleSignOutClick}>Sign Out</a>
我的事件处理程序:
handleSignOutClick (event) {
event.preventDefault();
fetch('/users/sign_out', {
method: 'DELETE',
mode: 'cors',
credentials: 'include',
redirect: 'follow',
});
}
在我的 ApplicationController 中:
def after_sign_in_path_for(resource)
resource.referrer
end
想知道是不是因为我使用 Fetch API 的方式不对?我能够在成功登录时重定向到一个页面。
我不知道你可以在锚点中删除。检查默认 sign_out 按钮后,我使用了
<a href="/users/sign_out" data-method="delete" rel="nofollow">Sign Out</a>