passing token in missing headers
This commit is contained in:
@@ -5,6 +5,9 @@ export function attachAuthInterceptors(client: AxiosInstance) {
|
|||||||
client.interceptors.request.use((config) => {
|
client.interceptors.request.use((config) => {
|
||||||
const token = tokenStore.get();
|
const token = tokenStore.get();
|
||||||
if (token) {
|
if (token) {
|
||||||
|
if (!config.headers) {
|
||||||
|
(config as any).headers = {};
|
||||||
|
}
|
||||||
config.headers.Authorization = `Bearer ${token}`;
|
config.headers.Authorization = `Bearer ${token}`;
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
|
|||||||
Reference in New Issue
Block a user