update auth
This commit is contained in:
parent
23afdc4df9
commit
ff3fb68219
12 changed files with 222 additions and 308 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import Axios, { type AxiosRequestConfig, type AxiosResponse } from 'axios'
|
||||
import keycloak from './keycloak'
|
||||
import { getToken } from './auth'
|
||||
|
||||
const http = Axios.create({
|
||||
timeout: 1000000000, // เพิ่มค่า timeout
|
||||
|
|
@ -10,10 +10,9 @@ const http = Axios.create({
|
|||
|
||||
http.interceptors.request.use(
|
||||
async function (config: AxiosRequestConfig<any>) {
|
||||
// await keycloak.updateToken(1)
|
||||
config.headers = config.headers ?? {}
|
||||
const token = keycloak.token
|
||||
// const token = localStorage.getItem("access_token")
|
||||
const token = await getToken()
|
||||
|
||||
if (token) config.headers.Authorization = `Bearer ${token}`
|
||||
return config
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue