1
回答
axios 跨域请求过滤器的问题
开发十年,就只剩下这套Java开发体系了   

axios   request  加了过滤器   增加了  请求头 header 中  Authorization 参数

不加可以跨域   加了提示

 

 

         send() {
                instance.interceptors.request.use(config=>{
                    let bearer='Bearer '
                    console.log(config)
                    config.headers.Authorization=bearer.concat('eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0YXJhIiwic3ViIjoiYWxsIiwiYXVkIjoiMTAzODgxNTgwNDAyMzU3MDQzMyIsImV4cCI6IjIwMTgtMTAtMTYgMTE6NDY6MjYiLCJpYXQiOiIyMDE4LTEwLTA5IDExOjQ2OjI2IiwianRpIjoiODQxMDFiODJjNjQ4NDZjYjg2M2IwZGZhMTNiZWJiZTEifQ.W2TDNdUGM4VYatzW1evyZYUgOLobelN8e7yJexd-LAehsrnU5vbKl6oCjE3IeWW6gVkXOE7pKLxsC8MEGsasMDQ5lNs-CT_OjXr9rzzVISksXmyvVw8u6fbsJ9mI77Q-zNZyO4ibUh0x4dg9w_ErzRuLG671B5Fxcn7wXiLsc1wuI-6LYfd5e6qxogBAba_cmwQ-cEXK3R2dYSP73XfunwpKUCE5UALXWUd1dF1FoUwsTo8lqpl02yJbPrwvisRvsw0Nz6J1khyFLZmUfbK2ty0ogO1a_my-_ysKrbiwLh54D3adl04zKIQE9jj-9hIonv-VQQPUNVnw2hzK8doCoA')
                    return config
                })
                instance.post("/journalismApi").then(res => {
                    this.msg = res.data.data.toutiao
                    console.log(this.msg)
                })

            }

 

<无标签>
举报
NotFound403
发帖于6天前 1回/25阅
顶部