Commit 2fbc2509 by zhuzhequan

axios 请求头 添加 timestamp和uuid

parent de4b50da
......@@ -21,6 +21,7 @@
"pinia": "^2.1.7",
"qrcode": "^1.5.4",
"splitpanes": "^3.1.5",
"uuid": "^13.0.0",
"vue": "^3.4.19",
"vue-dompurify-html": "^5.1.0",
"vue-router": "^4.3.0",
......@@ -6433,6 +6434,19 @@
"dev": true,
"license": "MIT"
},
"node_modules/uuid": {
"version": "13.0.0",
"resolved": "https://registry.npmmirror.com/uuid/-/uuid-13.0.0.tgz",
"integrity": "sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w==",
"funding": [
"https://github.com/sponsors/broofa",
"https://github.com/sponsors/ctavan"
],
"license": "MIT",
"bin": {
"uuid": "dist-node/bin/uuid"
}
},
"node_modules/vite": {
"version": "5.4.19",
"resolved": "https://registry.npmmirror.com/vite/-/vite-5.4.19.tgz",
......
......@@ -23,6 +23,7 @@
"pinia": "^2.1.7",
"qrcode": "^1.5.4",
"splitpanes": "^3.1.5",
"uuid": "^13.0.0",
"vue": "^3.4.19",
"vue-dompurify-html": "^5.1.0",
"vue-router": "^4.3.0",
......
import router from '@/router'
import Axios from 'axios'
import { showError } from '@/utils/ui.ts'
import { v4 as uuidv4 } from 'uuid'
const axios = Axios.create({
baseURL: import.meta.env.VITE_API_BASE,
timeout: 60 * 60 * 1000, //半小时
......@@ -22,6 +22,8 @@ axios.interceptors.request.use(
const token = getToken()
if (token) {
config.headers['jwt-token'] = token
config.headers.timestamp = new Date().getTime()
config.headers.uuid = uuidv4().replace(/-/g, '')
}
return config
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment