sxszzhrrt
V2EX  ›  Java

关于 Vue 与 sa-token 交互的问题?

  •  
  •   sxszzhrrt · Oct 17, 2023 · 3574 views
    This topic created in 972 days ago, the information mentioned may be changed or developed.

    后端程序开发中鉴权使用了 sa-token ,前端是 Vue 开发,请问要不要 sa-token 在登录的时候显式的返回 token 信息给前端的 Vue ?还是说直接 login(id)通过后端自动注入 cookie 就可以了?

    8 replies    2023-10-18 10:47:35 +08:00
    webszy
        1
    webszy  
       Oct 17, 2023
    这跟 vue 无关吧
    winnie414
        2
    winnie414  
       Oct 17, 2023
    第二种是个什么方式?前后端分离一般都是第一种吧
    linauror
        3
    linauror  
       Oct 17, 2023
    前后端分离要使用无 cookie 模式,getTokenInfo 获取到 token 后返回给前端
    liuhuihao
        4
    liuhuihao  
       Oct 17, 2023
    你说的两种方式不就是 token 和 cookie 么,两种都行。token 更灵活一些,跨域一类的
    nekomiao
        5
    nekomiao  
       Oct 17, 2023
    试下不就知道了,就几行代码的事,有你问的功夫都写完好几遍了。
    wuyiccc
        6
    wuyiccc  
       Oct 17, 2023
    sa-token 关掉 cookie 模式, 然后 getTokenValue 在接口返回给前端
    liangyun
        7
    liangyun  
       Oct 17, 2023
    推荐 token, 但是你得说说你们的主要场景才能得出更佳的判断啊
    cxsz
        8
    cxsz  
       Oct 18, 2023
    登录接口返回一个 token 给前端,然后让前端把它放 header 里面就可以了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5531 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 06:57 · PVG 14:57 · LAX 23:57 · JFK 02:57
    ♥ Do have faith in what you're doing.