Skip to content

使用hapi时,无法跟随鉴权失败自动跳转到登录页 #222

@wolf-joe

Description

@wolf-joe

What version of HAPI is running?

hapi version: 0.15.3

What platform is your computer?

Linux 5.15.0-164-generic x86_64 x86_64

What issue are you seeing?

考虑到公网暴露服务的安全性,我使用了caddy+oauth插件的方式将hapi暴露在公网上。
流程如下:

  1. 浏览器访问地址,oauth插件发现用户未登录/token失效,返回302响应
  2. 浏览器跟随302响应跳转到登录页

但在使用hapi时,如果用户oauth登录状态过期,页面会停留在token输入页,输入token后会报错“failed to fetch”,而不是跳转到oauth登录页。

What steps can reproduce the bug?

  1. 启动hapi
  2. 让后端接口返回302(如oauth失效/手动魔改)
  3. 打开hapi,输入token
  4. hapi在前端报错

What is the expected behavior?

解决方案:让hapi能跟随302跳转到登录页
进阶需求:让hapi能配置无需token的鉴权方案,方便oauth场景/localhost场景使用。

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions