refresh issues

This commit is contained in:
Jake Kasper
2025-09-04 10:21:12 -05:00
parent 3ddbc32fe0
commit e4524432e7
3 changed files with 30 additions and 3 deletions

View File

@@ -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) => {