lib/ folder.
🛡️ Security Interceptors (IAM)
Communication with the Identity Access Management (IAM) microservice and protected routes require constant credential validation. Instead of manually attaching the token to every request, theiamApi.js instance utilizes network interceptors (interceptors.request).
Before any request leaves the browser, the interceptor automatically injects the JWT token (if it exists) and configures the Accept-Language header based on the user’s current route to support language switching in server responses.
⏱️ Expired Session Handling (401 Unauthorized)
To prevent a user from remaining in a private view if their JWT token has expired or is invalid, the Axios instance implements a response interceptor (interceptors.response).
If the server responds with an HTTP 401 status code, the interceptor automatically clears the credentials from local storage (localStorage) and securely redirects the user to the corresponding login screen, respecting the current session language.