test
This commit is contained in:
22
js-demo/server/interceptor.ts
Normal file
22
js-demo/server/interceptor.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import axios from "axios"
|
||||
import { getEncodeHeader } from "./tool/index"
|
||||
|
||||
// axios 拦截器
|
||||
const api = axios.create({
|
||||
baseURL: "https://live-open.biliapi.com"
|
||||
// baseURL: "http://test-live-open.biliapi.net" //test
|
||||
})
|
||||
|
||||
// 鉴权加密处理headers,下次请求自动带上
|
||||
api.interceptors.request.use(config => {
|
||||
const headers = getEncodeHeader(
|
||||
config.data,
|
||||
global.appKey,
|
||||
global.appSecret
|
||||
)
|
||||
console.log('headers: ', headers)
|
||||
config.headers = headers
|
||||
return config
|
||||
})
|
||||
|
||||
export default api
|
||||
Reference in New Issue
Block a user