base commit
This commit is contained in:
@@ -5,3 +5,15 @@ export const apiClient = axios.create({
|
||||
baseURL: apiBaseURL,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
|
||||
apiClient.interceptors.request.use((config) => {
|
||||
try {
|
||||
const token = localStorage.getItem('craftshop_auth_token')
|
||||
if (!token) return config
|
||||
config.headers = config.headers ?? {}
|
||||
config.headers.Authorization = `Bearer ${token}`
|
||||
return config
|
||||
} catch {
|
||||
return config
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user