File tree 4 files changed +81
-26
lines changed
4 files changed +81
-26
lines changed Original file line number Diff line number Diff line change 1
1
VUE_APP_SELF_HOST = https://web-tech.tw/openchat
2
2
VUE_APP_OCJI_HOST = https://web-tech.tw/recv/openchat
3
3
4
- VUE_APP_TURNSTILE_SITE_KEY = " 0x4AAAAAAAr6LY1hBUbTBkVA"
5
-
6
4
VUE_APP_SARA_INTE_HOST = https://web-tech.tw/sara
7
5
VUE_APP_SARA_RECV_HOST = https://web-tech.tw/recv/sara
8
6
VUE_APP_SARA_TOKEN_NAME = unified_token
7
+
8
+ VUE_APP_TURNSTILE_SITE_KEY = " 0x4AAAAAAAr6LY1hBUbTBkVA"
9
+
10
+ VUE_APP_ZEBRA_TOKEN_NAME = " zebra"
Original file line number Diff line number Diff line change 12
12
"autoprefixer" : " ^10" ,
13
13
"core-js" : " ^3.8.3" ,
14
14
"dayjs" : " ^1.11.12" ,
15
+ "nanoid" : " ^5.0.7" ,
15
16
"postcss" : " ^8" ,
16
17
"tailwindcss" : " ^3" ,
17
18
"ua-parser-js" : " ^1.0.38" ,
Original file line number Diff line number Diff line change 3
3
import Vue from "vue" ;
4
4
import axios from "axios" ;
5
5
6
+ import {
7
+ nanoid ,
8
+ } from "nanoid" ;
9
+
6
10
const {
7
11
VUE_APP_OCJI_HOST : ocjiRecvHost ,
8
12
VUE_APP_SARA_TOKEN_NAME : saraTokenName ,
13
+ VUE_APP_ZEBRA_TOKEN_NAME : zebraTokenName ,
9
14
} = process . env ;
10
15
11
16
// Full config: https://github.com/axios/axios#request-config
@@ -22,12 +27,19 @@ const axiosClient = axios.create(config);
22
27
axiosClient . interceptors . request . use (
23
28
// Do something before request is sent
24
29
( config ) => {
30
+ let zebraToken = localStorage . getItem ( zebraTokenName ) ;
31
+ if ( ! zebraToken ) {
32
+ zebraToken = nanoid ( ) ;
33
+ localStorage . setItem ( zebraTokenName , zebraToken ) ;
34
+ }
35
+ config . headers [ "X-Zebra-Code" ] = zebraToken ;
36
+
25
37
const saraToken = localStorage . getItem ( saraTokenName ) ;
26
38
if ( ! saraToken ) {
27
39
return config
28
40
}
29
-
30
41
config . headers [ "Authorization" ] = `SARA ${ saraToken } ` ;
42
+
31
43
return config ;
32
44
} ,
33
45
// Do something with request error
You can’t perform that action at this time.
0 commit comments