axios发送的POST请求始终返回未授权(Unauthorized),尽管头部中设置了有效的JWT。
创始人
2024-09-28 19:30:51
0
  1. 确保JWT的格式正确,包括header、payload和signature部分。
  2. 在创建axios实例时,设置默认的Authorization头部(或者其他名字):
import axios from 'axios';

const api = axios.create({
  headers: { Authorization: `Bearer ${localStorage.getItem('jwt')}` }
});

  1. 在需要发送的请求中,设置Authorization头部:
api.post('/api/endpoint', data, {
  headers: { Authorization: `Bearer ${localStorage.getItem('jwt')}` }
})
  .then(response => {
    // handle response
  })
  .catch(error => {
    // handle error
  });
  1. 检查JWT是否已超时或已被撤销。
  2. 检查服务器端是否正确验证了JWT。

相关内容

热门资讯

透视有挂!wepoker私局辅... 透视有挂!wepoker私局辅助(透视)wepoker有脚本吗,教程指南(有挂讲解)-哔哩哔哩1、下...
wepoker脚本!德州透视h... wepoker脚本!德州透视hhpoker(透视)器-切实解密真的有挂wepoker脚本!德州透视h...
pokemmo辅助工具!德普之... pokemmo辅助工具!德普之星透视辅助软件激活码(透视)挂-原来透视有挂一、德普之星透视辅助软件激...
透视有挂!wepoker买脚本... 透视有挂!wepoker买脚本靠谱吗(透视)约局吧开挂神器是真的吗,教程要领(有挂方略)-哔哩哔哩1...
sohoo辅助!hhpoker... sohoo辅助!hhpoker到底可以透视吗(透视)方法-本来推荐真的是有挂1、许多玩家不知道hhp...
透视辅助!pokemmo手机版... 透视辅助!pokemmo手机版修改器(透视)佛手大菠萝13道挂哪里,教程教材(有挂实锤)-哔哩哔哩佛...
epoker免费透视脚本!hh... epoker免费透视脚本!hhpoker真的假的(透视)app-本来曝光存在有挂1、下载好epoke...
透视开挂!wepokerplu... 透视开挂!wepokerplus万能挂(透视)wpk透视工作室,教程总结(有挂透视)-哔哩哔哩1.w...
wpk辅助插件!wepoker... wpk辅助插件!wepoker辅助透视软件(透视)神器-真是辅助真的是有挂运wepoker辅助透视软...
透视曝光!hhpoker是真的... 透视曝光!hhpoker是真的吗(透视)hhpoker辅助挂,教程练习(有挂工具)-哔哩哔哩1)hh...