Build [v.1.3.6]

This commit is contained in:
Daniel Bedeleanu
2026-04-11 17:14:22 +03:00
parent 775808506f
commit 704934165f
27 changed files with 738 additions and 685 deletions

View File

@@ -21,18 +21,15 @@ export const getBackendUrl = () => {
* [C-01] Axios instance cu JWT Bearer token în header
* și interceptor pentru 401 Unauthorized (token expired)
*/
const axiosInstance = axios.create({
baseURL: getBackendUrl()
});
const axiosInstance = axios.create({});
axiosInstance.interceptors.request.use((config) => {
if (!config.baseURL) {
config.baseURL = getBackendUrl(); // called at request time — always correct
}
const token = getToken();
console.log('[API] Request interceptor - token exists:', !!token, 'URL:', config.url);
if (token) {
config.headers.Authorization = `Bearer ${token}`;
console.log('[API] Authorization header set');
} else {
console.warn('[API] No token found in localStorage');
}
return config;
}, (error) => Promise.reject(error));
@@ -43,7 +40,7 @@ axiosInstance.interceptors.response.use(
// [L-01] Handle 401 Unauthorized — token expired
if (error.response?.status === 401) {
clearAuth();
if (typeof window !== 'undefined') {
if (typeof window !== 'undefined' && !window.location.pathname.includes('/login')) {
window.location.href = '/login';
}
}