refresh issues
This commit is contained in:
@@ -10,6 +10,9 @@ export const apiClient = axios.create({
|
||||
timeout: 10000,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Cache-Control': 'no-cache',
|
||||
'Pragma': 'no-cache',
|
||||
'Expires': '0',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -33,6 +36,15 @@ apiClient.interceptors.request.use(
|
||||
if (token && token !== 'undefined' && token !== 'null') {
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
// Prevent browser/proxy caching of GET requests by adding a timestamp
|
||||
if ((config.method || 'get').toLowerCase() === 'get') {
|
||||
config.headers['Cache-Control'] = 'no-cache';
|
||||
config.headers['Pragma'] = 'no-cache';
|
||||
config.headers['Expires'] = '0';
|
||||
const params = new URLSearchParams(config.params || {});
|
||||
if (!params.has('_ts')) params.set('_ts', Date.now().toString());
|
||||
config.params = Object.fromEntries(params.entries());
|
||||
}
|
||||
return config;
|
||||
},
|
||||
(error) => {
|
||||
|
||||
Reference in New Issue
Block a user